/* Form controls and protocol content */
input,
textarea,
select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  font-size: 16px;
}

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

select {
  padding-right: 3.4rem;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--primary) 50%),
    linear-gradient(135deg, var(--primary) 50%, transparent 50%),
    linear-gradient(to right, rgba(24, 52, 135, 0.18), rgba(24, 52, 135, 0.18));
  background-position:
    calc(100% - 18px) calc(1.2rem),
    calc(100% - 12px) calc(1.2rem),
    calc(100% - 2.8rem) 50%;
  background-size:
    6px 6px,
    6px 6px,
    1px 60%;
  background-repeat: no-repeat;
}

.document-heading {
  padding: 1.5rem 1.6rem 0.6rem;
  background: linear-gradient(180deg, rgba(24, 52, 135, 0.06), transparent);
}
.document-kicker,
.document-heading p:first-child {
  margin: 0 0 0.35rem;
  color: var(--primary-deep);
  font-weight: 800;
}
.document-heading h2 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2rem);
}
.document-heading .document-note {
  max-width: 860px;
  margin-top: 0.8rem;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.5;
}

.protocol-page {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 0.65rem 1.6rem 1.8rem;
}
.protocol-page-2 {
  border-top: 1px dashed rgba(127, 149, 171, 0.6);
  background: linear-gradient(180deg, rgba(24, 52, 135, 0.03), transparent);
}

fieldset {
  width: 100%;
  min-width: 0;
  margin: 1rem 0 2rem;
  padding: 0;
  border: 0;
}
legend {
  width: 100%;
  margin-bottom: 1rem;
  padding-bottom: 0.55rem;
  border-bottom: 2px solid var(--primary-deep);
  color: var(--primary-deep);
  font-size: 1.16rem;
  font-weight: 800;
}

.subheading {
  margin: 0.4rem 0 1rem;
  text-align: center;
  text-decoration: underline;
  font-weight: 700;
}

.form-row {
  margin: 0 0 1rem;
}
.numbered-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 2.1rem minmax(180px, 300px) 1fr;
  gap: 0.7rem;
  align-items: center;
}
.number {
  align-self: start;
  padding-top: 0.85rem;
  color: var(--primary-deep);
  font-weight: 800;
}
.label-text {
  font-weight: 700;
}
.textarea-row {
  align-items: start;
}
.textarea-row .label-text {
  padding-top: 0.85rem;
}

.split-row {
  grid-template-columns: 2.1rem 1fr 1fr;
  align-items: start;
}

.split-row label,
.stacked-fields label,
.signature-grid label,
.count-grid label,
.sample-meta label,
.map-grid label,
.compound-fields label {
  display: grid;
  gap: 0.4rem;
  color: var(--ink);
  font-weight: 700;
}

.continued-fieldset {
  margin-top: 0.5rem;
}
.count-row,
.compound-row,
.transport-row,
.map-row,
.sketch-row,
.signature-row {
  align-items: start;
}
.count-grid {
  grid-column: 2 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 0.8rem;
}
.count-grid .wide {
  grid-column: 1 / -1;
}
.compound-fields {
  display: grid;
  grid-template-columns: minmax(150px, 0.45fr) minmax(220px, 1fr);
  gap: 0.8rem;
}
.stacked-fields {
  grid-column: 2 / -1;
  display: grid;
  gap: 0.8rem;
}
.map-grid {
  grid-column: 2 / -1;
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(140px, 1fr) minmax(
      140px,
      1fr
    );
  gap: 0.8rem;
  align-items: end;
}
.sketch-wrap {
  grid-column: 2 / -1;
}
.sketch-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.55rem;
  font-weight: 700;
}
#sketchCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1200 / 620;
  border: 2px solid var(--line-strong);
  border-radius: 14px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8);
  touch-action: none;
}
.hint {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}
.signature-grid {
  grid-column: 2 / -1;
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 0.8rem;
}

.samples-heading {
  display: grid;
  grid-template-columns: minmax(180px, 0.45fr) 1fr;
  gap: 1.5rem;
  align-items: start;
  padding-bottom: 1.25rem;
}
.sample-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.6rem 1rem;
}
.table-scroll {
  overflow: auto;
  padding: 0 1.1rem 1.5rem;
}
table {
  width: 100%;
  min-width: 1500px;
  border-collapse: collapse;
  table-layout: fixed;
}
th,
td {
  padding: 0.34rem;
  border: 1px solid var(--line-strong);
  vertical-align: top;
}
th {
  background: linear-gradient(180deg, #eef3f8, #e4ebf3);
  color: var(--primary-deep);
  font-size: 0.82rem;
  line-height: 1.25;
  text-align: center;
  overflow-wrap: anywhere;
  hyphens: auto;
}
td input,
td textarea,
td select {
  min-height: 40px;
  padding: 0.5rem;
  border: 0;
  border-radius: 8px;
  background-color: transparent;
  box-shadow: none;
}
td textarea {
  min-height: 74px;
}
.row-actions-column {
  width: 52px;
}

/* Mode-specific protocol controls */
.mode-control,
.gps-panel {
  grid-column: 3;
}

#appShell[data-active-mode="standard"] .standard-single-row {
  grid-template-columns: 2.1rem minmax(0, 1fr);
}

#appShell[data-active-mode="standard"] .count-grid {
  grid-template-columns: repeat(2, minmax(140px, 1fr));
}

.gps-panel {
  display: grid;
  gap: 0.9rem;
  padding: 1rem;
  border: 1px solid rgba(24, 52, 135, 0.24);
  border-radius: 16px;
  background: linear-gradient(145deg, #fffdf8, #f5f7fb);
}

.gps-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.gps-actions .button {
  flex: 0 0 auto;
}

.gps-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.gps-grid label {
  display: grid;
  gap: 0.4rem;
  color: var(--ink);
  font-weight: 700;
}

.privacy-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

/* Water sampling protocol */
.water-page {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: grid;
  gap: 0.25rem;
}

.water-form-grid,
.measurement-grid {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.water-field,
.measurement-grid label,
.water-signature-grid label {
  min-width: 0;
  display: grid;
  gap: 0.4rem;
  color: var(--ink);
  font-weight: 700;
}

.water-field-wide {
  grid-column: 1 / -1;
}

.measurement-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 1rem;
}

.sensory-grid {
  margin-top: 0.5rem;
}

.water-detail-panel {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid rgba(24, 52, 135, 0.24);
  border-radius: 16px;
  background: linear-gradient(145deg, #fffdf8, #f5f7fb);
}

.water-detail-panel h3 {
  margin: 0 0 0.9rem;
  color: var(--primary-deep);
  font-size: 1rem;
}

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

.water-signature-grid {
  grid-column: auto;
  margin-top: 1rem;
}

#appShell[data-active-pnp-type="water"] .tabbar {
  grid-template-columns: 1fr;
}

/* Water measurement time series */
.water-table-hint {
  margin-bottom: 0.75rem;
}

.water-table-scroll {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  padding: 0 0 0.35rem;
  border: 1px solid rgba(24, 52, 135, 0.18);
  border-radius: 14px;
  background: #fff;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-inline: contain;
  contain: inline-size;
}

.water-data-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  table-layout: fixed;
}

.water-measurement-table {
  min-width: 1160px;
}

.water-summary-table {
  min-width: 1040px;
}

.water-data-table th {
  padding: 0.58rem 0.42rem;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #eef3f8, #e4ebf3);
  color: var(--primary-deep);
  font-size: 0.76rem;
  line-height: 1.2;
  text-align: center;
  vertical-align: middle;
}

.water-data-table td {
  padding: 0.25rem;
  border: 1px solid var(--line-strong);
  background: #fff;
  vertical-align: middle;
}

.water-data-table td input,
.water-data-table td select {
  min-height: 42px;
  padding: 0.48rem 0.5rem;
  border: 0;
  border-radius: 7px;
  background-color: transparent;
  box-shadow: none;
}

.water-data-table td input:focus,
.water-data-table td select:focus {
  background-color: #fff;
}

.water-time-cell {
  min-width: 108px;
  color: var(--primary-deep);
  font-weight: 800;
  text-align: center;
}

.water-time-cell select {
  min-width: 100px;
  font-weight: 750;
}

.water-summary-wrap {
  margin-top: 0.75rem;
}

.water-summary-table output {
  display: block;
  min-height: 1.4rem;
  padding: 0.25rem;
  font-weight: 750;
  text-align: center;
}

.water-sensory-section {
  margin-top: 1.15rem;
}

legend,
label,
.label-text,
.document-heading,
.document-note,
.water-field,
.water-detail-panel,
.gps-panel {
  min-width: 0;
  overflow-wrap: anywhere;
}

.gps-actions .button.is-capturing {
  border-color: #b85b55;
  background: #fff3f1;
  color: var(--danger);
}
