/* Phase 4 field-report workflow layer — presentation only.
   Adds the stepper, save-state, review, and measurement readability styles.
   No acceptance logic lives in this file. */

:root {
  --p4-line: #d9dee8;
  --p4-ink: #15233e;
  --p4-slate: #566076;
  --p4-sky: #2f6f9f;
  --p4-amber: #8a5200;
  --p4-red: #b3261e;
  --p4-green: #146b46;
}

/* ---------- stepper ---------- */
.p4-stepper {
  max-width: 100%;
  overflow: hidden;
  position: sticky;
  top: 0;
  z-index: 40;
  background: #fff;
  border-bottom: 1px solid var(--p4-line);
  padding: 8px 12px 0;
}
.p4-steps {
  max-width: 100%;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  list-style: none;
  margin: 0;
  padding: 0 0 8px;
  scrollbar-width: thin;
}
.p4-step-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid var(--p4-line);
  border-radius: 8px;
  background: #fff;
  color: var(--p4-slate);
  font: 500 13px/1.25 inherit;
  white-space: nowrap;
  cursor: pointer;
}
.p4-step-btn:hover { background: #f4f7fb; }
.p4-step-btn[aria-current="step"] {
  border-color: var(--p4-ink);
  background: var(--p4-ink);
  color: #fff;
}
.p4-step-btn:focus-visible { outline: 3px solid #7dbcdc; outline-offset: 2px; }
.p4-step-num {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid currentColor;
  font-size: 11px;
  font-weight: 700;
  flex: none;
}
.p4-step-state {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.85;
}
.p4-step-btn[data-state="incomplete"] .p4-step-state { color: var(--p4-amber); }
.p4-step-btn[data-state="complete"] .p4-step-state { color: var(--p4-green); }
.p4-step-btn[aria-current="step"] .p4-step-state { color: #cfe3f3; }

.p4-progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
  font-size: 12px;
  color: var(--p4-slate);
  flex-wrap: wrap;
}
.p4-bar {
  flex: 1 1 160px;
  height: 6px;
  min-width: 120px;
  border-radius: 99px;
  background: #e8edf4;
  overflow: hidden;
}
.p4-bar > span { display: block; height: 100%; background: var(--p4-sky); }

.p4-stepnav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin: 24px 0 8px;
  padding-top: 16px;
  border-top: 1px solid var(--p4-line);
}
.p4-stepnav .p4-spacer { flex: 1; }
.p4-btn {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--p4-line);
  background: #fff;
  color: var(--p4-ink);
  font: 600 14px/1 inherit;
  cursor: pointer;
}
.p4-btn:hover { background: #f4f7fb; }
.p4-btn-primary { background: var(--p4-ink); border-color: var(--p4-ink); color: #fff; }
.p4-btn-primary:hover { background: #0d1930; }
.p4-btn:focus-visible { outline: 3px solid #7dbcdc; outline-offset: 2px; }
.p4-btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------- notices ---------- */
.p4-notice {
  border: 1px solid var(--p4-line);
  border-left: 4px solid var(--p4-sky);
  border-radius: 8px;
  background: #f5f9fd;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--p4-ink);
  margin-bottom: 16px;
}
.p4-notice strong { display: block; margin-bottom: 4px; }
.p4-notice-warn { border-left-color: var(--p4-amber); background: #fdf6ec; }
.p4-example-banner {
  border-left-color: var(--p4-amber);
  background: #fdf3e2;
  font-weight: 600;
}

/* ---------- save / sync state ---------- */
.p4-savebar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--p4-slate);
}
.p4-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--p4-line);
  border-radius: 99px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 600;
  background: #fff;
  color: var(--p4-slate);
}
.p4-chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.p4-chip[data-tone="ok"] { color: var(--p4-green); border-color: #bfe0cd; background: #f1f9f4; }
.p4-chip[data-tone="warn"] { color: var(--p4-amber); border-color: #ecd3ac; background: #fdf6ec; }
.p4-chip[data-tone="bad"] { color: var(--p4-red); border-color: #eac4c1; background: #fdf1f0; }
.p4-chip[data-tone="busy"] { color: var(--p4-sky); border-color: #c3daea; background: #f2f8fc; }

/* ---------- review ---------- */
.p4-review-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.p4-review-card {
  border: 1px solid var(--p4-line);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fff;
}
.p4-review-card h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--p4-slate); }
.p4-review-card p { margin: 0; font-size: 14px; font-weight: 600; color: var(--p4-ink); }
.p4-list { margin: 8px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.6; }
.p4-list li { margin-bottom: 2px; }
.p4-jump {
  background: none;
  border: none;
  padding: 0;
  color: var(--p4-sky);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}
.p4-ack {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid #ecd3ac;
  background: #fdf6ec;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
}
.p4-ack input { width: 20px; height: 20px; margin-top: 1px; flex: none; }

/* ---------- measurements readability ---------- */
.p4-ir-wrap { max-height: 62vh; overflow: auto; border: 1px solid var(--p4-line); border-radius: 8px; }
.p4-ir-wrap table { margin: 0; }
.p4-ir-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #eef3f9;
  color: var(--p4-ink);
  font-weight: 700;
  box-shadow: inset 0 -1px 0 var(--p4-line);
}
.p4-unit {
  font-size: 11px;
  font-weight: 600;
  color: var(--p4-slate);
  margin-left: 4px;
}
.p4-missing {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--p4-amber);
  margin-top: 4px;
}
tr.p4-row-missing td:first-child { box-shadow: inset 3px 0 0 var(--p4-amber); }
.p4-sec-status { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-left: 6px; }

.p4-undo {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--p4-ink);
  color: #fff;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.p4-undo button {
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: transparent;
  color: #fff;
  font: 600 13px/1 inherit;
  cursor: pointer;
}

/* touch targets */
.p4-scope input,
.p4-scope select,
.p4-scope textarea,
.p4-scope button { min-height: 44px; }
.p4-scope .checkbox-row input[type="checkbox"] { width: 22px; height: 22px; min-height: 22px; }

@media (max-width: 720px) {
  .p4-ir-wrap { max-height: none; border: none; }
  .p4-ir-wrap table,
  .p4-ir-wrap thead,
  .p4-ir-wrap tbody,
  .p4-ir-wrap tr,
  .p4-ir-wrap td { display: block; width: 100%; }
  .p4-ir-wrap thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .p4-ir-wrap tr {
    border: 1px solid var(--p4-line);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 10px;
    background: #fff;
  }
  .p4-ir-wrap td { border: none; padding: 6px 0; }
  .p4-ir-wrap td::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--p4-slate);
    margin-bottom: 3px;
  }
}

@media print {
  .p4-stepper,
  .p4-stepnav,
  .p4-undo,
  .p4-savebar { display: none !important; }
  .tab-content { display: block !important; }
  .p4-ir-wrap { max-height: none; overflow: visible; border: none; }
}
