:root {
  color-scheme: light;
  --ink: #102033;
  --muted: #5e6c7c;
  --line: #d7dee8;
  --surface: #ffffff;
  --soft: #f4f7fb;
  --accent: #005aa8;
  --accent-strong: #003f7a;
  --sky: #0c9bd8;
  --steel: #34485f;
  --warning: #b76512;
  --critical: #b42318;
  --shadow: 0 18px 50px rgba(17, 36, 58, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #eef3f8 0%, #f8fafc 48%, #eef3f8 100%);
}

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

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px clamp(14px, 4vw, 42px);
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid rgba(215, 222, 232, 0.95);
  backdrop-filter: blur(16px);
}

.brand,
.nav-actions,
.report-actions,
.button-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  min-width: 0;
}

.cejka-logo {
  width: 94px;
  height: 48px;
  object-fit: contain;
  object-position: left center;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1rem;
  letter-spacing: 0;
}

.brand small,
.intro-panel p,
.section-heading p,
.empty-gallery,
.empty-report p,
small,
.muted {
  color: var(--muted);
}

.nav-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-actions a {
  padding: 9px 11px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.nav-actions a:hover {
  background: var(--soft);
  color: var(--ink);
}

.app-shell {
  width: min(1180px, calc(100% - 24px));
  margin: 18px auto 70px;
}

.intro-panel,
.form-section,
.report-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.intro-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  padding: clamp(18px, 4vw, 32px);
  margin-bottom: 18px;
  border-top: 5px solid var(--accent);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 720px;
  margin-bottom: 10px;
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 1.45rem;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.05rem;
}

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

.form-section,
.report-preview {
  padding: clamp(16px, 3vw, 28px);
}

.section-heading {
  margin-bottom: 18px;
}

.section-heading.with-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
}

.section-heading.compact {
  margin-bottom: 14px;
}

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

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

label {
  display: grid;
  gap: 7px;
  color: #304358;
  font-size: 0.9rem;
  font-weight: 800;
}

.wide,
.full {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid #cad5e1;
  border-radius: 8px;
  padding: 11px 13px;
  color: var(--ink);
  background: #fbfdff;
  outline: none;
}

textarea {
  min-height: 130px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0, 90, 168, 0.14);
}

.primary-action,
.submit-button,
.ghost-button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0 16px;
  border: 0;
  cursor: pointer;
  font-weight: 900;
  text-align: center;
}

.submit-button {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--sky));
  box-shadow: 0 12px 26px rgba(0, 90, 168, 0.24);
}

.submit-button:hover {
  background: linear-gradient(135deg, var(--accent-strong), #007dbc);
}

.ghost-button {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.ghost-button:hover {
  border-color: #9eb4cc;
  background: #f8fbff;
}

.hidden-file {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

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

.empty-gallery {
  grid-column: 1 / -1;
  padding: 20px;
  border: 1px dashed #aebdca;
  border-radius: 8px;
  background: var(--soft);
  text-align: center;
  font-weight: 800;
}

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

.photo-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #dce5ee;
}

.photo-card div {
  display: grid;
  gap: 2px;
  padding: 10px;
}

.photo-card strong {
  overflow-wrap: anywhere;
  font-size: 0.86rem;
}

.photo-card button {
  width: calc(100% - 20px);
  min-height: 36px;
  margin: 0 10px 10px;
  border: 1px solid #f0b5ad;
  border-radius: 8px;
  color: var(--critical);
  background: #fff6f4;
  cursor: pointer;
  font-weight: 800;
}

.measurement-panel {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.measurement-list {
  display: grid;
  gap: 12px;
}

.measurement-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(90px, 0.5fr) 90px minmax(160px, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.remove-row {
  min-height: 46px;
  border: 1px solid #f0b5ad;
  border-radius: 8px;
  color: var(--critical);
  background: #fff;
  cursor: pointer;
  font-weight: 800;
}

.report-preview {
  margin-top: 18px;
}

.report-sheet {
  min-height: 320px;
  padding: clamp(18px, 3vw, 32px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.empty-report {
  display: grid;
  min-height: 240px;
  place-content: center;
  text-align: center;
}

.report-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 3px solid var(--accent);
}

.report-header h2 {
  margin: 0 0 8px;
  font-size: 2rem;
}

.report-header img {
  width: 120px;
  height: 72px;
  object-fit: contain;
}

.report-section {
  margin: 0 0 24px;
  break-inside: avoid;
}

.report-section h3 {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  color: var(--accent-strong);
}

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

.report-field {
  min-height: 68px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.report-field span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.report-field strong {
  overflow-wrap: anywhere;
}

.report-photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.report-photo-grid figure {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.report-photo-grid img {
  width: 100%;
  max-height: 320px;
  display: block;
  object-fit: contain;
  background: #eef3f8;
}

.report-photo-grid figcaption {
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
}

.report-table th,
.report-table td {
  padding: 9px 10px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.report-table th {
  background: #eef5fb;
  color: var(--steel);
  font-size: 0.82rem;
}

.report-notes {
  min-height: 80px;
  padding: 12px 14px;
  border-left: 4px solid var(--accent);
  background: #f8fbff;
  white-space: pre-wrap;
}

@media (max-width: 900px) {
  .intro-panel,
  .section-heading.with-action {
    grid-template-columns: 1fr;
  }

  .report-actions,
  .button-cluster {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

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

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

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

  .remove-row {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
  }

  .nav-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
  }

  .nav-actions a {
    padding: 10px 6px;
    text-align: center;
    font-size: 0.78rem;
  }

  .app-shell {
    width: min(100% - 14px, 1180px);
    margin-top: 8px;
  }

  .report-actions,
  .button-cluster,
  .field-grid,
  .stp-grid,
  .photo-grid,
  .measurement-row,
  .report-grid,
  .report-photo-grid {
    grid-template-columns: 1fr;
  }

  .report-actions,
  .button-cluster {
    display: grid;
  }

  h1 {
    font-size: 2.2rem;
  }
}

@media print {
  @page {
    margin: 0.45in;
    size: letter;
  }

  body {
    background: #fff;
  }

  .topbar,
  .intro-panel,
  .field-form,
  .report-preview > .section-heading {
    display: none !important;
  }

  .app-shell,
  .report-preview,
  .report-sheet {
    width: auto;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .report-sheet {
    display: block;
  }

  .empty-report {
    display: none;
  }

  .report-field,
  .report-photo-grid figure,
  .report-table th,
  .report-table td {
    break-inside: avoid;
  }

  .report-photo-grid img {
    max-height: 260px;
  }
}
