:root {
  color-scheme: light;
  --ink: #1f2933;
  --muted: #667085;
  --line: #d7dee8;
  --surface: #ffffff;
  --surface-2: #f3f6f8;
  --nav: #25313d;
  --accent: #0f766e;
  --accent-dark: #0b5d56;
  --warning: #b45309;
  --danger: #b42318;
  --shadow: 0 12px 32px rgba(31, 41, 51, 0.12);
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface-2);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  padding: 14px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 18px rgba(31, 41, 51, 0.06);
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-logo {
  display: block;
  width: clamp(180px, 24vw, 300px);
  height: auto;
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 26px;
}

h2 {
  margin-bottom: 5px;
  font-size: 22px;
}

.topbar-actions,
.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.primary-button,
.secondary-button,
.icon-button,
.danger-button {
  min-height: 40px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 9px 14px;
  font-weight: 700;
}

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

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

.secondary-button,
.icon-button {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.secondary-button:hover,
.icon-button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.danger-button {
  background: #fff;
  color: var(--danger);
  border-color: #f0b8b2;
}

.app-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100vh - 76px);
}

.sidebar {
  position: sticky;
  top: 76px;
  align-self: start;
  min-height: calc(100vh - 76px);
  padding: 16px;
  background: var(--nav);
}

.nav-item {
  width: 100%;
  min-height: 44px;
  margin-bottom: 8px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #dce5ed;
  font-weight: 700;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: #ffffff;
  color: var(--nav);
}

.workspace {
  width: 100%;
  max-width: 1280px;
  padding: 22px;
}

.project-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cbd5df;
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  border-color: var(--accent);
}

.form-panel {
  display: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.form-panel.active {
  display: block;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.section-heading p {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
}

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

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

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

.table-actions {
  justify-content: flex-end;
  margin-bottom: 12px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.pdf-link {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 12px;
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.pdf-link:hover {
  border-color: var(--accent);
}

.rocip-title-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(180px, 240px) minmax(160px, 220px);
  gap: 14px;
  align-items: end;
  margin-bottom: 16px;
}

.rocip-title-row h3 {
  margin: 0;
  font-size: 24px;
}

.checklist-section {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.checklist-section > h3 {
  margin: 0;
  padding: 9px 12px;
  background: #08e015;
  color: #111827;
  font-size: 20px;
}

.checklist-section > p,
.checklist-section > label,
.checklist-section > .field-grid {
  margin: 12px;
}

.note-line {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  color: var(--ink);
  font-weight: 700;
}

.checklist-table-wrap {
  width: 100%;
  overflow-x: auto;
  border-top: 1px solid var(--line);
}

.checklist-table {
  min-width: 760px;
  border: 0;
}

.checklist-table th {
  background: #d8d8d8;
  color: #111827;
  font-size: 13px;
  text-transform: none;
}

.checklist-table th:nth-child(2),
.checklist-table th:nth-child(3),
.checklist-table td:nth-child(2),
.checklist-table td:nth-child(3) {
  width: 96px;
  text-align: center;
}

.checklist-table td {
  border-right: 1px solid var(--line);
}

.checklist-table td:last-child,
.checklist-table th:last-child {
  border-right: 0;
}

.checklist-table input[type="radio"] {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 2px auto;
  accent-color: var(--accent);
}

.jarr-card {
  display: grid;
  gap: 16px;
}

.jarr-header {
  display: grid;
  grid-template-columns: minmax(160px, 240px) minmax(180px, 1fr) 112px;
  gap: 16px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.jarr-logo {
  display: block;
  width: 100%;
  height: auto;
}

.jarr-header h3 {
  margin: 0;
  font-size: 36px;
  font-weight: 900;
}

.jarr-header p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.energy-wheel {
  width: 112px;
  height: 112px;
  object-fit: contain;
}

.jarr-stop-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  border: 2px solid var(--danger);
  border-radius: 8px;
  padding: 12px;
  background: #fff7f6;
}

.jarr-stop-row span {
  color: var(--danger);
  font-weight: 900;
}

.inline-check {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.inline-check input,
.hazard-grid input[type="checkbox"] {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.hazard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
  margin: 12px;
}

.hazard-grid fieldset {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.hazard-grid legend {
  padding: 0 6px;
  color: var(--accent-dark);
  font-weight: 900;
}

.hazard-grid label {
  display: flex;
  grid-template-columns: none;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 0;
  font-size: 13px;
  font-weight: 600;
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #eef3f6;
  color: #344054;
  font-size: 12px;
  text-transform: uppercase;
}

td input,
td select {
  min-width: 112px;
}

td:last-child {
  width: 64px;
  text-align: center;
}

.row-remove {
  min-width: 36px;
  min-height: 36px;
  border: 1px solid #f0b8b2;
  border-radius: 6px;
  background: #fff;
  color: var(--danger);
  font-weight: 800;
}

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

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

.draft-title {
  margin: 0 0 3px;
  font-weight: 800;
}

.draft-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  border: 1px dashed #aab7c4;
  border-radius: 8px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 36px));
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  padding: 12px 14px;
  background: #17212b;
  color: #fff;
  box-shadow: var(--shadow);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

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

  .sidebar {
    position: static;
    display: flex;
    min-height: auto;
    overflow-x: auto;
    padding: 10px;
  }

  .nav-item {
    width: auto;
    min-width: max-content;
    margin: 0 8px 0 0;
  }

  .project-strip,
  .field-grid.two,
  .field-grid.three,
  .hazard-grid {
    grid-template-columns: 1fr;
  }

  .section-heading {
    display: block;
  }

  .rocip-title-row {
    grid-template-columns: 1fr;
  }

  .jarr-header {
    grid-template-columns: 1fr;
  }

  .energy-wheel {
    width: 96px;
    height: 96px;
  }
}

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

  .brand-group {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .brand-logo {
    width: min(100%, 280px);
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .workspace {
    padding: 14px;
  }

  .draft-item {
    grid-template-columns: 1fr;
  }
}

@media print {
  .topbar,
  .sidebar,
  .table-actions,
  .row-remove,
  .toast {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .app-shell {
    display: block;
  }

  .workspace {
    max-width: none;
    padding: 0;
  }

  .project-strip,
  .form-panel {
    box-shadow: none;
    border-color: #999;
  }

  .form-panel {
    display: none !important;
  }

  .form-panel.active {
    display: block !important;
  }
}
