:root {
  --bg: #f6f7f8;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #697586;
  --line: #d8dee6;
  --accent: #1565c0;
  --accent-dark: #0f4d92;
  --good: #1f7a4d;
  --warn: #b45f06;
  --bad: #b42318;
  --soft: #edf3f8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

[hidden] {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.app-view {
  min-height: 100vh;
}

body.authenticated .login-view {
  display: none !important;
}

body.authenticated .app-view {
  display: block !important;
}

body:not(.authenticated) .app-view {
  display: none !important;
}

.login-card {
  width: min(100%, 360px);
  display: grid;
  gap: 10px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.login-card p {
  margin-bottom: 6px;
}

.login-error {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #f2b8b5;
  border-radius: 6px;
  background: #fff7f6;
  color: var(--bad);
  font-weight: 700;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

p {
  margin: 4px 0 0;
  color: var(--muted);
}

main {
  max-width: 1220px;
  margin: 0 auto;
  padding: 18px;
}

.site-picker {
  display: grid;
  grid-template-columns: 52px minmax(180px, 300px) minmax(220px, 360px) auto;
  align-items: center;
  gap: 8px;
}

label {
  color: var(--muted);
  font-weight: 600;
}

input,
select,
button,
textarea {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

button {
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover {
  background: var(--accent-dark);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.tab {
  border-color: transparent;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: transparent;
}

.tab.active {
  background: #fff;
  border-color: var(--line);
  border-bottom-color: #fff;
  color: var(--accent);
  font-weight: 700;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.category {
  margin-bottom: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.category summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 10px 14px;
  background: var(--soft);
  cursor: pointer;
  font-weight: 700;
}

.category-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
}

.node {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 148px;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.node h3 {
  margin: 0 0 6px;
  font-size: 14px;
  line-height: 1.35;
}

.node-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef1f4;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pill.good {
  background: #e7f5ee;
  color: var(--good);
}

.pill.warn {
  background: #fff4e5;
  color: var(--warn);
}

.pill.bad {
  background: #fdecea;
  color: var(--bad);
}

.drop {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 104px;
  border: 1px dashed #aab6c4;
  border-radius: 6px;
  background: #f9fafb;
  text-align: center;
  color: var(--muted);
  overflow: hidden;
}

.drop.dragging {
  border-color: var(--accent);
  background: #eef6ff;
}

.drop.readonly {
  border-style: solid;
  background: #f2f4f7;
}

.drop.mobile-only-blocked {
  border-style: solid;
  background: #fff7ed;
  color: #9a5b00;
}

.drop input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop input:disabled {
  cursor: not-allowed;
}

.preview {
  width: 100%;
  height: 104px;
  object-fit: contain;
  background: #eef1f4;
}

.device-note {
  border-color: #f2c078;
  background: #fffaf2;
}

.review-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.review-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.review-category {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  background: #f5f8fb;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.15;
}

.review-card img {
  width: 100%;
  aspect-ratio: 5 / 4;
  object-fit: contain;
  background: #eef1f4;
  cursor: zoom-in;
}

.review-card .body {
  padding: 8px 10px 9px;
}

.review-card h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.18;
}

.review-card p {
  margin-top: 4px;
  line-height: 1.2;
}

.review-card .node-meta {
  margin-top: 6px;
}

.review-card .actions {
  margin-top: 8px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
}

.download-button.disabled {
  background: #eef1f4;
  color: #8993a1;
  cursor: not-allowed;
}

.download-button.ready {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.download-button.ready:hover {
  background: var(--accent-dark);
}

.report-box {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.generation-progress {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #bcd5f2;
  border-radius: 8px;
  background: #f3f8ff;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--accent-dark);
}

.progress-head span {
  color: var(--muted);
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #d8e7f8;
}

.progress-bar {
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  animation: progress-slide 1.1s ease-in-out infinite;
}

@keyframes progress-slide {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(260%);
  }
}

.retake-note {
  margin-bottom: 12px;
  border-color: #f2b8b5;
  background: #fff7f6;
}

.retake-note p {
  margin: 6px 0 0;
  color: var(--muted);
}

.missing-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.missing-list ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #17202a;
  color: #fff;
  box-shadow: 0 10px 30px rgba(23, 32, 42, 0.24);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(10, 15, 22, 0.86);
}

.lightbox.open {
  display: flex;
}

.lightbox-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  place-items: center;
  gap: 12px;
}

.lightbox-content img {
  max-width: 100%;
  max-height: calc(100vh - 116px);
  object-fit: contain;
  border-radius: 6px;
  background: #111827;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.lightbox-close {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 51;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(23, 32, 42, 0.82);
}

.lightbox-title {
  margin: 0;
  max-width: min(96vw, 1280px);
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(23, 32, 42, 0.82);
  color: #fff;
  text-align: center;
}

body.lightbox-open {
  overflow: hidden;
}

@media (max-width: 860px) {
  .app-header {
    position: static;
    display: block;
  }

  .site-picker {
    grid-template-columns: 1fr;
    margin-top: 12px;
  }

  .status-strip,
  .category-body,
  .review-grid,
  .missing-list {
    grid-template-columns: 1fr;
  }

  .tabs {
    overflow-x: auto;
  }

  .node {
    grid-template-columns: 1fr;
  }
}
