:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #5e6875;
  --line: #d8dee6;
  --panel: #ffffff;
  --page: #f4f6f8;
  --blue: #1f6feb;
  --blue-dark: #154ea6;
  --green: #197a43;
  --amber: #9c6212;
  --red: #bb2d3b;
  --steel: #64748b;
  --shadow: 0 18px 45px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px clamp(16px, 4vw, 44px);
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue-dark);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.6rem, 3vw, 2.25rem);
}

h2 {
  margin-bottom: 16px;
  font-size: 1.1rem;
}

.header-actions,
.form-actions,
.record-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.compact {
  min-height: 42px;
  padding: 0 14px;
}

.app-shell {
  display: block;
  padding: 24px clamp(16px, 4vw, 44px) 44px;
}

.workspace {
  min-width: 0;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2px;
  width: min(520px, 100%);
  margin-bottom: 18px;
  padding: 4px;
  background: #dfe5ec;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.project-panel {
  margin-bottom: 18px;
  padding: clamp(16px, 3vw, 22px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.project-panel h2 {
  margin-bottom: 0;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.job-actions {
  display: flex;
  align-items: end;
  gap: 14px;
}

.job-actions label {
  min-width: min(320px, 58vw);
}

.saved-state,
.field-message {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.field-message {
  min-height: 18px;
}

.field-message.error {
  color: var(--red);
}

.tab {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab.active {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 1px 5px rgba(23, 32, 42, 0.1);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

form,
.records-list,
.summary-grid > section,
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

form {
  padding: clamp(16px, 3vw, 28px);
}

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

fieldset {
  display: grid;
  gap: 14px;
  min-width: 0;
  margin: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

legend {
  padding: 0 6px;
  font-weight: 800;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

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

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(31, 111, 235, 0.18);
  border-color: var(--blue);
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.attachments-panel,
.checklist-panel,
.notes-panel {
  margin-top: 20px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.score {
  min-width: 58px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #eef4ff;
  color: var(--blue-dark);
  font-size: 1.1rem;
  font-weight: 800;
  text-align: center;
}

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

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

.attachment-item {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
}

.attachment-item input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin-right: 9px;
}

.attachment-notes {
  margin-top: 12px;
}

.check-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.check-item input {
  width: 18px;
  height: 18px;
  min-height: 18px;
}

.check-item strong {
  display: block;
  font-size: 0.95rem;
}

.check-item span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.weight {
  min-width: 28px;
  border-radius: 999px;
  background: #e8edf3;
  color: #344052;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 28px;
  text-align: center;
}

.photo-preview,
.record-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.photo-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.camera-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.photo-tile {
  position: relative;
  margin: 0;
}

.photo-tile img,
.record-photos img {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.remove-photo {
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: 5px;
  min-height: 24px;
  border: 0;
  border-radius: 5px;
  background: rgba(23, 32, 42, 0.82);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 800;
}

.form-actions {
  justify-content: flex-end;
  margin-top: 22px;
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
  min-height: 42px;
  border-radius: 6px;
  font-weight: 800;
}

.primary-button {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #ffffff;
  padding: 0 18px;
}

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

.ghost-button,
.danger-button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  padding: 0 14px;
}

.tag-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 84px;
  justify-content: center;
}

.danger-button {
  color: var(--red);
}

.small {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.85rem;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
}

.icon-button svg,
.tag-button svg,
.camera-button svg,
.search svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.records-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 12px;
  margin-bottom: 14px;
}

.search {
  position: relative;
  display: block;
}

.search span {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.search input {
  padding-left: 42px;
}

.records-list {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.empty {
  margin: 0;
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.record-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
}

.record-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.record-main h3 {
  margin-bottom: 4px;
  font-size: 1rem;
}

.record-main p,
.record-notes {
  margin-bottom: 0;
  color: var(--muted);
}

.status-pill {
  border-radius: 999px;
  padding: 6px 10px;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 800;
}

.risk-Low {
  background: var(--green);
}

.risk-Elevated {
  background: #6f7d1c;
}

.risk-Moderate {
  background: var(--amber);
}

.risk-High {
  background: #b45309;
}

.risk-Critical {
  background: var(--red);
}

.job-card {
  cursor: pointer;
}

.active-job {
  border-color: var(--blue);
  box-shadow: inset 4px 0 0 var(--blue);
}

dl {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

dt {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

dd {
  margin: 3px 0 0;
  font-weight: 800;
}

.record-actions {
  justify-content: flex-end;
  margin-top: 14px;
}

.confirm-dialog {
  width: min(440px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 70px rgba(23, 32, 42, 0.26);
}

.confirm-dialog::backdrop {
  background: rgba(23, 32, 42, 0.42);
}

.confirm-dialog form {
  border: 0;
  border-radius: 8px;
  box-shadow: none;
  padding: 22px;
}

.confirm-dialog h2 {
  margin-bottom: 10px;
}

.confirm-dialog p {
  color: var(--muted);
  line-height: 1.45;
}

.dialog-input {
  margin-top: 16px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.simple-confirm .dialog-input {
  display: none;
}

.simple-confirm .dialog-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.simple-confirm .dialog-actions button {
  min-height: 48px;
}

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

.metric {
  padding: 18px;
}

.metric span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
}

.summary-grid > section {
  padding: 18px;
}

.bar-row {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6ebf1;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
}

.concern-list {
  display: grid;
  gap: 10px;
}

.concern {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.concern strong {
  display: block;
  margin-bottom: 4px;
}

.concern span {
  color: var(--muted);
  font-size: 0.85rem;
}

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

}

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

  .header-actions {
    justify-content: flex-end;
  }

  .form-grid,
  .checklist,
  .attachments-grid,
  .summary-grid,
  .records-toolbar,
  .project-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

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

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

@media print {
  .tabs,
  .form-actions,
  .header-actions,
  .records-toolbar,
  body {
    background: #ffffff;
  }

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

  .view {
    display: block;
    margin-bottom: 18px;
  }
}
