:root {
  --bg: #eef2f1;
  --panel: #ffffff;
  --ink: #15211f;
  --muted: #66736f;
  --line: #d9e1de;
  --accent: #176f5b;
  --accent-strong: #0f5a4a;
  --accent-soft: #e3f2ee;
  --warn: #a93d31;
  --shadow: 0 18px 45px rgba(19, 37, 33, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

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

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 78px;
  padding: 14px clamp(16px, 4vw, 44px);
  color: #ffffff;
  background: #182522;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.eyebrow,
.section-kicker,
.summary-label {
  margin: 0;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.app-header .eyebrow {
  color: #8fd6c4;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.05;
}

.publish-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  color: #c9d8d4;
  font-size: 12px;
  font-weight: 700;
}

.publish-links a {
  color: #c9f0e6;
  text-decoration: none;
}

.publish-links a:hover {
  text-decoration: underline;
}

h2 {
  font-size: 23px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.view-switch {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.view-switch-button {
  min-width: 56px;
  min-height: 34px;
  padding: 6px 9px;
  border: 0;
  border-radius: 5px;
  color: #c9d8d4;
  background: transparent;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.view-switch-button:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.view-switch-button.is-active {
  color: #ffffff;
  background: var(--accent);
}

.print-logo-slot {
  display: none;
}

.save-status {
  min-width: 74px;
  color: #c9d8d4;
  font-size: 13px;
  text-align: right;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  width: 42px;
  height: 42px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.icon-button.text-action {
  width: auto;
  min-width: 58px;
  font-size: 12px;
  font-weight: 850;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.16);
}

.secondary-button {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

.secondary-button:hover {
  background: var(--accent-strong);
}

.ghost-button {
  color: var(--accent-strong);
  background: #eef7f4;
}

.ghost-button:hover {
  color: #ffffff;
  background: var(--accent-strong);
}

.wide-button {
  width: 100%;
  margin-top: 10px;
}

.icon-button.danger:hover {
  background: rgba(169, 61, 49, 0.75);
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-action {
  position: relative;
  overflow: hidden;
}

.file-action input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(220px, 270px) minmax(0, 1fr);
  gap: 22px;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px clamp(14px, 3vw, 34px) 42px;
}

.side-panel {
  position: sticky;
  top: 100px;
  align-self: start;
  display: grid;
  gap: 12px;
}

.summary-block,
.section-nav {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
}

.summary-block {
  padding: 15px;
}

.summary-block strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.section-nav {
  display: grid;
  padding: 8px;
}

.section-nav a {
  padding: 10px 11px;
  border-radius: 6px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.section-nav a:hover {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.form-stack {
  display: grid;
  gap: 18px;
}

.form-section {
  padding: clamp(16px, 3vw, 26px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.grid {
  display: grid;
  gap: 13px;
  margin-bottom: 14px;
}

.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.span-2 {
  grid-column: span 2;
}

label,
.field-group {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: #33413e;
  font-size: 13px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #cbd6d2;
  border-radius: 7px;
  color: var(--ink);
  background: #fbfdfc;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(23, 111, 91, 0.18);
  border-color: var(--accent);
}

.field-group {
  margin-bottom: 15px;
}

.field-title {
  color: var(--ink);
}

.section-note,
.feedback-privacy {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.logo-uploader {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(150px, 220px);
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.logo-uploader .section-note {
  margin: 3px 0 0;
}

.logo-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.logo-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  padding: 8px;
  border: 1px dashed #b9c8c3;
  border-radius: 8px;
  color: var(--muted);
  background: #ffffff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.logo-preview img {
  display: block;
  max-width: 100%;
  max-height: 58px;
  object-fit: contain;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chips label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid #cdd9d5;
  border-radius: 8px;
  background: #fbfdfc;
  cursor: pointer;
}

.chips input {
  width: 16px;
  height: 16px;
  min-height: auto;
  accent-color: var(--accent);
}

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

.docs-grid label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.docs-grid select {
  min-height: 36px;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
}

.check-row input {
  width: 16px;
  height: 16px;
  min-height: auto;
  margin-top: 2px;
  accent-color: var(--accent);
}

.honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.feedback-status {
  min-height: 18px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.feedback-status[data-status="success"] {
  color: var(--accent-strong);
  font-weight: 750;
}

.feedback-status[data-status="error"] {
  color: var(--warn);
  font-weight: 750;
}

.feedback-status[data-status="pending"] {
  color: var(--muted);
}

.privacy-list {
  display: grid;
  gap: 8px;
  color: #33413e;
}

.privacy-list p {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.generator-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.generators-list {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.generator-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.generator-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.generator-card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 850;
}

.remove-generator {
  width: 34px;
  height: 34px;
  border: 1px solid #d8c5c1;
  border-radius: 8px;
  color: var(--warn);
  background: #fff8f7;
  font-weight: 850;
  cursor: pointer;
}

.remove-generator:hover {
  color: #ffffff;
  background: var(--warn);
}

.photo-editor {
  display: grid;
  gap: 14px;
}

.photo-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.photo-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.photo-upload-progress {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid #b9d8cf;
  border-radius: 8px;
  background: #f3faf7;
}

.photo-upload-progress[hidden] {
  display: none;
}

.photo-progress-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  font-size: 13px;
}

.photo-progress-heading span {
  color: var(--accent-strong);
  font-weight: 850;
}

.photo-upload-progress progress {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border: 0;
  border-radius: 6px;
  color: var(--accent);
  background: #d9e7e2;
}

.photo-upload-progress progress::-webkit-progress-bar {
  background: #d9e7e2;
}

.photo-upload-progress progress::-webkit-progress-value {
  background: var(--accent);
}

.photo-upload-progress progress::-moz-progress-bar {
  background: var(--accent);
}

.photo-upload-progress p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.icon-button:disabled,
.secondary-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.photo-list {
  display: grid;
  gap: 14px;
}

.empty-photos {
  margin: 0;
  padding: 16px;
  border: 1px dashed #b9c8c3;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.photo-card {
  display: grid;
  grid-template-columns: minmax(180px, 280px) minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.photo-preview {
  width: 100%;
  height: 200px;
  border: 1px solid #cbd6d2;
  border-radius: 6px;
  background: #ffffff;
  object-fit: contain;
}

.photo-card-fields {
  display: grid;
  align-content: start;
  gap: 10px;
}

.photo-number {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

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

.photo-actions .secondary-button {
  min-height: 34px;
  padding: 6px 10px;
}

.photo-actions button:disabled {
  opacity: 0.45;
  cursor: default;
}

.photo-remove {
  border-color: #d8c5c1;
  color: var(--warn);
  background: #fff8f7;
}

.photo-remove:hover {
  color: #ffffff;
  background: var(--warn);
}

.photo-print-pages {
  display: none;
}

@media screen {
  body.view-report #foto {
    display: none;
  }

  body.view-photos .form-section:not(#foto) {
    display: none;
  }

  body.view-report .section-nav a[href="#foto"] {
    display: none;
  }

  body.view-photos .section-nav a:not([href="#foto"]) {
    display: none;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
  }

  .section-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .save-status {
    margin-left: 0;
  }

  .cols-2,
  .cols-3,
  .cols-4,
  .docs-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .section-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .docs-grid label {
    grid-template-columns: 1fr;
  }

  .logo-uploader {
    grid-template-columns: 1fr;
  }

  .logo-controls {
    flex-direction: column;
  }

  .generator-toolbar,
  .generator-card-header {
    align-items: stretch;
    flex-direction: column;
  }

  .remove-generator {
    width: 100%;
  }

  .photo-card {
    grid-template-columns: 1fr;
  }

  .photo-preview {
    height: 220px;
  }

  .photo-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
}

@media print {
  :root {
    --bg: #ffffff;
    --panel: #ffffff;
    --line: #bfc8c5;
    --shadow: none;
  }

  @page {
    size: A4;
    margin: 10mm;
  }

  body {
    background: #ffffff;
    font-size: 10.5pt;
  }

  .app-header {
    position: static;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    min-height: auto;
    padding: 0 0 7mm;
    color: #111111;
    background: #ffffff;
    border-bottom: 1px solid #111111;
  }

  .print-logo-slot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: 42mm;
    height: 18mm;
  }

  .print-logo-slot img {
    display: block;
    max-width: 42mm;
    max-height: 18mm;
    object-fit: contain;
  }

  body:not(.has-report-logo) .print-logo-slot {
    display: none;
  }

  .app-header .eyebrow {
    color: #555555;
  }

  .publish-links {
    display: none;
  }

  h1 {
    font-size: 20pt;
  }

  h2 {
    font-size: 14pt;
  }

  .header-actions,
  .side-panel,
  .no-print {
    display: none;
  }

  .app-shell {
    display: block;
    width: 100%;
    padding: 0;
  }

  .form-stack {
    display: block;
  }

  .form-section {
    break-inside: avoid;
    page-break-inside: avoid;
    margin: 0 0 6mm;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  body.print-report-only #foto {
    display: none;
  }

  body.print-photos-only .form-section:not(#foto) {
    display: none;
  }

  body.print-complete #foto {
    break-before: page;
    page-break-before: always;
  }

  .section-heading {
    margin-bottom: 4mm;
    padding: 3mm 0 2mm;
    border-bottom: 1px solid #222222;
  }

  .grid,
  .docs-grid {
    gap: 2.5mm;
    margin-bottom: 3mm;
  }

  label,
  .field-group {
    font-size: 8.5pt;
  }

  input,
  select,
  textarea {
    min-height: 8mm;
    padding: 1.5mm 2mm;
    border-color: #888888;
    border-radius: 0;
    background: #ffffff;
  }

  textarea {
    min-height: 18mm;
  }

  .chips {
    gap: 2mm;
  }

  .chips label,
  .docs-grid label,
  .generator-card {
    min-height: auto;
    padding: 1.5mm 2mm;
    border-radius: 0;
    background: #ffffff;
  }

  .generator-toolbar {
    display: block;
  }

  .secondary-button,
  .remove-generator {
    display: none;
  }

  .logo-uploader,
  .logo-controls,
  .logo-preview {
    display: none;
  }

  .photo-print-pages {
    display: block;
  }

  .photo-print-page {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(0, 1fr));
    gap: 3mm;
    height: 242mm;
    break-after: page;
    page-break-after: always;
  }

  .photo-print-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .photo-print-card {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    min-height: 0;
    overflow: hidden;
    border: 1px solid #777777;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .photo-print-card img {
    width: 100%;
    height: 100%;
    min-height: 0;
    background: #ffffff;
    object-fit: contain;
  }

  .photo-print-caption {
    padding: 1.7mm 2mm;
    border-top: 1px solid #bfc8c5;
    font-size: 8pt;
    line-height: 1.25;
  }

  .photo-print-caption strong {
    display: block;
    font-size: 8.5pt;
  }

  .photo-print-caption p {
    margin: 0.8mm 0 0;
    overflow-wrap: anywhere;
  }

  .generator-card-header {
    padding-bottom: 1.5mm;
  }
}
