:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d9dee7;
  --primary: #173b67;
  --primary-dark: #102c4d;
  --accent: #e7802b;
  --danger: #9f2d2d;
  --ok: #2f6d4f;
  --shadow: 0 6px 18px rgba(16, 24, 40, 0.07);
}

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

.app-header {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 18px max(18px, calc((100vw - 1180px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 20px;
}

.header-logo {
  width: 128px;
  height: auto;
  flex-shrink: 0;
}

.header-divider {
  width: 1px;
  height: 48px;
  background: #d7e0ea;
}

.header-copy h1 {
  margin: 0 0 4px;
}

.header-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.eyebrow { font-size: 12px; letter-spacing: .12em; font-weight: 800; color: var(--primary); }
h1 { margin: 2px 0 0; font-size: 25px; line-height: 1.1; }
.project-title { margin-top: 5px; color: var(--muted); font-size: 14px; }
.header-actions { display: flex; gap: 8px; }
.shell { width: min(1180px, calc(100% - 28px)); margin: 22px auto 80px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}
.visit-card { padding: 18px; }
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px;
}
.sticky-heading { border-bottom: 1px solid var(--line); }
.section-number { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .09em; color: var(--accent); }
h2 { margin: 3px 0 0; font-size: 20px; }
.save-state, .pill {
  font-size: 12px;
  padding: 5px 9px;
  background: #eef3f8;
  border: 1px solid #dbe3ec;
  border-radius: 999px;
  color: var(--primary);
}
.notice {
  margin: 0 18px 16px;
  padding: 11px 13px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 7px;
  color: #344054;
  font-size: 14px;
}
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
label { display: block; font-size: 13px; font-weight: 700; color: #344054; }
input, select, textarea {
  width: 100%;
  margin-top: 6px;
  border: 1px solid #cfd5df;
  border-radius: 8px;
  padding: 10px 11px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(23, 59, 103, .18); border-color: var(--primary); }
.required { color: var(--danger); }
.help { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; font-weight: 400; }

details { border-top: 1px solid var(--line); }
details:first-of-type { border-top: 0; }
summary {
  cursor: pointer;
  list-style: none;
  padding: 15px 18px;
  font-weight: 800;
  background: #fbfcfd;
  user-select: none;
}
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; float: right; color: var(--primary); font-size: 18px; line-height: 1; }
details[open] summary::after { content: "-"; }
.details-body { padding: 16px 18px 20px; }
.check-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 12px;
  margin-bottom: 14px;
}
.check-grid label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #f9fafb;
  border: 1px solid #eaecf0;
  border-radius: 8px;
  padding: 9px;
  font-weight: 600;
}
.check-grid input { width: auto; margin: 2px 0 0; }

button {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
  font: inherit;
}
button.primary { background: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-dark); }
button.secondary { background: #edf2f7; color: var(--primary); border: 1px solid #d7e0ea; }
button.ghost { background: transparent; color: var(--primary); padding: 7px 9px; }
button.danger { color: var(--danger); }
.form-actions, .export-actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; padding: 18px; border-top: 1px solid var(--line); }
.spacer { flex: 1; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin: 12px 0 18px; }
.photo-card { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.photo-card img { width: 100%; height: 105px; object-fit: cover; display: block; }
.photo-card .caption { font-size: 11px; padding: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.area-list { padding: 0 18px; }
.area-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.area-item:first-child { border-top: 0; }
.area-item-actions { display: flex; gap: 4px; }
.muted { color: var(--muted); font-size: 13px; }
.print-report { display: none; }

@media (max-width: 900px) {
  .grid.cols-4, .check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .app-header { position: static; align-items: flex-start; flex-direction: column; }
  .header-actions { width: 100%; }
  .header-actions button { flex: 1; }
  .shell { width: min(100% - 16px, 1180px); margin-top: 10px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .check-grid { grid-template-columns: 1fr; }
  .visit-card, .section-heading, .details-body, summary { padding-left: 13px; padding-right: 13px; }
  .notice { margin-left: 13px; margin-right: 13px; }
  .form-actions button { flex: 1 1 45%; }
  .spacer { display: none; }
}

@media print {
  body { background: #fff; color: #000; font-size: 10.5pt; }
  .no-print, #inspectionForm, .visit-card, #visitTools { display: none !important; }
  .app-header { position: static; border: 0; padding: 0 0 12px; }
  .app-header h1 { font-size: 18pt; }
  .shell { width: 100%; margin: 0; }
  .print-report { display: block; }
  .report-header { border-bottom: 2px solid #000; padding-bottom: 10px; margin-bottom: 14px; }
  .report-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 15px; margin: 10px 0 16px; }
  .report-area { break-inside: avoid; page-break-inside: avoid; margin-bottom: 18px; border-top: 1px solid #aaa; padding-top: 10px; }
  .report-area h3 { margin: 0 0 4px; font-size: 13pt; }
  .report-table { width: 100%; border-collapse: collapse; margin-top: 6px; }
  .report-table td { border: 1px solid #bbb; padding: 5px; vertical-align: top; }
  .report-table td:first-child { width: 28%; font-weight: 700; }
}
