/* The plan page's sections: fold cards, the requirements table, survey
   settings, day cards and the analyte picker. Ported from the old planner's
   look (styles.css 408–560, 1316–1780). */

/* --- Fold cards ------------------------------------------------------------------ */
/* Scrolled to (a link, find, focus), a section clears the sticky nav. */
.fold-card, .day-card { scroll-margin-top: 6rem; }
.fold-head { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem .9rem; }
.fold-head > h2 { flex: 0 0 auto; margin: 0; }
.fold-summary { flex: 1 1 12rem; min-width: 0; text-align: right; }
.fold-actions { display: flex; align-items: center; gap: .5rem; margin-left: auto; flex-wrap: wrap; }
.fold-summary + .fold-actions { margin-left: 0; }
.fold-body { margin-top: .85rem; }
button.fold-toggle { width: 40px; min-width: 40px; min-height: 40px; padding: 0; }
/* A caret drawn in CSS: up while open ("fold this away"), down while folded. */
.fold-caret {
  width: .5rem;
  height: .5rem;
  border-right: 2.5px solid currentColor;
  border-bottom: 2.5px solid currentColor;
  transform: translateY(.15rem) rotate(-135deg);
  transition: transform .15s ease;
}
.fold-toggle[aria-expanded="false"] .fold-caret { transform: translateY(-.15rem) rotate(45deg); }

/* --- Tables ------------------------------------------------------------------------ */
/* Positioned, so nothing absolutely placed inside a table escapes its scroll. */
.table-wrap { position: relative; overflow-x: auto; border-radius: .85rem; border: 1px solid var(--border); }
.req-table, .day-table { border-collapse: collapse; width: 100%; }
.day-table { min-width: 980px; }
.req-table th, .req-table td, .day-table th, .day-table td {
  border: 1px solid var(--border);
  padding: .3rem .4rem;
  text-align: center;
  font-size: .85rem;
  vertical-align: middle;
  background: white;
}
.req-table thead th, .day-table thead th {
  background: var(--header);
  text-transform: uppercase;
  font-size: .72rem;
  line-height: 1.2;
}
.req-table tbody tr:nth-child(even) > *, .day-table tbody tr:nth-child(even) > * { background: #f8fafc; }
/* The row being edited, tinted so it is obvious which line the typing goes into. */
.req-table tbody tr:focus-within > *, .day-table tbody tr:focus-within > * { box-shadow: inset 0 0 0 9999px var(--row-focus); }
.req-table input, .req-table select, .day-table input, .day-table select {
  margin: 0;
  padding: .35rem .45rem;
  font-size: .9rem;
  border-radius: .5rem;
  min-height: 36px;
}
.req-table input[type="checkbox"], .day-table input[type="checkbox"] { width: 1.3rem; height: 1.3rem; min-height: 0; }

/* The SEG column stays put while a wide table scrolls (an Excel-style freeze). */
.req-table .seg-col {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 9rem;
  text-align: left;
  box-shadow: 2px 0 0 var(--border);
}
.req-table thead .seg-col { z-index: 3; }
.req-table tbody th.seg-col { background: var(--card); }
.seg-name {
  min-height: 36px;
  padding: .2rem .3rem;
  background: none;
  color: var(--text);
  font-weight: 800;
  text-align: left;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.occ-col { min-width: 12rem; text-align: left; }
.area-col { min-width: 9rem; }
.num-cell { font-variant-numeric: tabular-nums; }
.required-input { width: 4.5rem; }
.media-row > * { background: var(--header) !important; font-weight: 700; text-transform: uppercase; font-size: .75rem; }

/* A SEG's analysis default: "INH +" in grey, or what it adds in words. */
.analyte-chip {
  display: inline-flex;
  margin: .25rem 0 0;
  min-height: 32px;
  padding: .15rem .55rem;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--switch);
  font-size: .78rem;
  font-weight: 700;
  white-space: nowrap;
}
.analyte-chip.is-default { background: #f1f5f9; color: var(--muted); font-weight: 600; }
.num-cell .analyte-chip { display: flex; margin: .3rem auto 0; width: max-content; }

/* The progress view: a tbody per SEG, so the stripes go by SEG rather than by
   line (a line's stripe would not reach the SEG cell merged down beside it),
   with a firmer rule between SEGs. Scoped to outrank the line stripes above. */
.req-table.progress-table tbody tr > * { background: white; }
.req-table.progress-table tbody:nth-of-type(even) tr > * { background: #f8fafc; }
.req-table.progress-table tbody + tbody tr:first-child > * { border-top: 2px solid #94a3b8; }
.progress-table .seg-cell { font-weight: 800; vertical-align: top; }
.progress-table .merged-cell { vertical-align: top; }
.progress-table .what-col { min-width: 10rem; text-align: left; }
.progress-table .num-cell { min-width: 4.5rem; font-size: .95rem; }
.progress-table .cell-note { display: block; font-size: .72rem; font-weight: 600; color: var(--muted); }
/* Noise is not an airborne contaminant: bold, in the switch colour, with a
   rule above it when it follows them. */
.req-table.progress-table tr.is-noise > :not(.seg-col):not(.merged-cell) { font-weight: 800; color: var(--switch); }
.req-table.progress-table tbody tr.is-noise > .what-col { background: #eef2ff; }
.req-table.progress-table tr.is-noise:not(:first-child) > * { border-top: 2px solid #a5b4fc; }
/* As the old overview: shaded while short of planning, a void, the
   requirement met. */
.req-table.progress-table tbody tr > .is-short { background: #f6eeba; font-weight: 700; }
.req-table.progress-table tbody tr > .has-void { background: #f6caca; }
.req-table.progress-table tbody tr > .is-met { background: var(--header); font-weight: 700; }
/* A double tap filters, so it must not zoom the page or select the word. */
.progress-table .can-filter {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
.progress-filter { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 0 0 .5rem; }

.chip-list { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .15rem .25rem .15rem .55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f8fafc;
  font-size: .8rem;
}
.chip-remove { min-height: 24px; width: 24px; padding: 0; border-radius: 999px; background: #e2e8f0; color: var(--text); font-size: .9rem; }
.occupation-add { width: 9rem !important; }

.add-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem; margin-top: .85rem; }
.add-row .form-field { flex: 0 1 18rem; }
.toggle-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1.2rem; margin-top: .85rem; }
.inline-toggle { margin-top: 0; font-size: .92rem; }

/* --- Survey settings ------------------------------------------------------------- */
.settings-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1rem; }
.settings-group { margin-bottom: 1rem; }
.settings-group h3 { margin-bottom: .5rem; }
.limit-field { font-size: .74rem; }
.method-setting {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: .6rem 1rem;
  padding: .6rem .75rem;
  margin-bottom: .5rem;
  border: 1px solid var(--border);
  border-radius: .75rem;
  background: #f8fafc;
}
.method-setting-name { flex: 1 1 12rem; min-width: 0; align-self: center; }
.method-setting .limit-field { flex: 0 1 12rem; }
.settings-notes p { margin: .3rem 0; }

/* Contaminants, SEGs and locations, as the old Survey Settings' lists. */
.setup-groups { grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.settings-subhead { margin: 1.2rem 0 .6rem; padding-top: .8rem; border-top: 1px solid var(--border); }
.setup-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.setup-item {
  display: flex;
  align-items: center;
  gap: .3rem;
  padding: .15rem .3rem .15rem .15rem;
  border: 1px solid var(--border);
  border-radius: .7rem;
  background: #f8fafc;
}
.setup-item-name {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 36px;
  padding: .3rem .45rem;
  justify-content: flex-start;
  flex-wrap: wrap;
  background: none;
  color: var(--text);
  font-weight: 700;
  text-align: left;
}
.setup-item-extra { color: var(--muted); font-weight: 400; font-size: .82rem; white-space: pre; }
.setup-item-code { color: var(--muted); font-family: var(--mono); font-size: .72rem; font-weight: 400; white-space: pre; }
.setup-add { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-top: .5rem; }
.setup-add input { flex: 1 1 8rem; width: auto; min-width: 0; margin-top: 0; padding: .5rem .65rem; }
.setup-actions { margin-top: .5rem; }
.setup-adopt { margin: .4rem 0 0; }
.round-add {
  flex: 0 0 auto;
  width: 28px;
  min-height: 28px;
  height: 28px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 1rem;
  font-weight: 800;
}
.link-button {
  min-height: 0;
  padding: 0;
  background: none;
  color: #1d4ed8;
  font-weight: 600;
  text-align: left;
  text-decoration: underline;
}

/* The setup dialogs. */
.setup-dialog h3, .contaminant-dialog h3 { margin: 1rem 0 .4rem; font-size: 1rem; }
.occupations-add, .paste-list { min-height: 4rem; }
.paste-list { min-height: 10rem; font-family: var(--mono); font-size: .9rem; }
.occupations-chips { margin-bottom: .2rem; }
.location-ticks { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .2rem .8rem; margin-bottom: .4rem; }
.location-tick { margin-top: 0; }
.location-photos .button-row { margin-top: .6rem; }
.location-photos .button-row .icon { width: 1.2rem; height: 1.2rem; margin-right: .35rem; }
.contaminant-picker input[type="search"] { margin-bottom: .6rem; }
.contaminant-options { display: grid; gap: .1rem; max-height: 55vh; overflow-y: auto; padding-right: .3rem; }
.contaminant-option { margin-top: 0; }
.contaminant-option[hidden] { display: none; }
.more-mark {
  display: inline-flex; align-items: center; justify-content: center; width: 1.3rem; height: 1.3rem; margin-left: auto;
  border-radius: 999px; background: #e2e8f0; color: var(--label); font-weight: 800; font-size: .85rem;
}
.way-options { display: grid; gap: .5rem; }
.way-option { align-items: flex-start; margin-top: 0; padding: .6rem .7rem; border: 1px solid var(--border); border-radius: .7rem; }
.way-option.is-blocked { opacity: .7; }
.way-detail { display: block; }
.fact-list { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .35rem 1rem; margin: 0; }
.fact-list .fact { display: contents; }
.fact-list dt { color: var(--label); font-weight: 600; }
.fact-list dd { margin: 0; }
.document-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.document-list li { display: flex; align-items: center; gap: .5rem; }
.heads-editor { display: grid; gap: .4rem; margin-bottom: .6rem; }
.heads-editor > button { justify-self: start; }
.head-row { display: grid; grid-template-columns: minmax(0, 1fr) 6.5rem auto auto; gap: .4rem; align-items: center; }
.head-row input { margin-top: 0; }
.head-default { margin-top: 0; }
.contaminant-choice { min-height: 14rem; }
@media (max-width: 560px) {
  .head-row { grid-template-columns: minmax(0, 1fr) 5.5rem; }
  .fact-list { grid-template-columns: minmax(0, 1fr); }
}

/* --- Day cards ----------------------------------------------------------------------- */
.day-card {
  margin-bottom: 1rem;
  padding: .8rem;
  border: 1px solid var(--border);
  border-radius: .9rem;
  background: #fff;
}
.day-card.is-outside { border-color: var(--warning-border); }
.day-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem 1rem; margin-bottom: .6rem; }
.day-date { flex: 0 1 11rem; }
.day-shift { flex: 0 1 9rem; }
.day-badges { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; padding-bottom: .55rem; }
.day-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-left: auto; padding-bottom: .2rem; }
.day-status.status-not-started, .day-status.status-empty { background: #f1f5f9; color: var(--label); }
.day-status.status-in-progress { border-color: #93c5fd; background: #eff6ff; color: #1d4ed8; }
.day-status.status-complete { border-color: #86efac; background: #f0fdf4; color: #166534; }
.day-status.status-signed-off { border-color: #166534; background: #166534; color: #fff; }
.day-issues { margin: 0 0 .5rem; padding-left: 1.2rem; color: var(--danger); font-size: .9rem; font-weight: 600; }
.day-blanks { margin: 0 0 .5rem; }
.day-table .row-no { width: 2.1rem; min-width: 2.1rem; padding: 0 .15rem; color: var(--muted); }
.day-table .slot-col { min-width: 6.5rem; }
.day-table .seg-cell { min-width: 9rem; }
/* A SEG or method that needs no more planning: light in the drop-down. */
.day-table option.is-met { color: #94a3b8; }
.day-table .occ-cell { min-width: 9rem; }
.day-table .name-cell { min-width: 12rem; }
/* A row's note: light with none, black with one. */
.day-table .note-cell { width: 3rem; text-align: center; }
.note-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 2.2rem; height: 2.2rem; min-height: 0; padding: 0;
  border-radius: 999px; background: #f1f5f9; color: #94a3b8; border: 1px solid var(--border);
}
.note-btn .icon { width: 1.1rem; height: 1.1rem; }
.note-btn.has-note { background: #0f172a; color: #fff; border-color: #0f172a; }
.note-dialog textarea { min-height: 6rem; }
.day-table .del-col { width: 2.5rem; }
.delete-row-btn {
  width: 1.9rem;
  height: 1.9rem;
  min-height: 0;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #fecaca;
  background: #fee2e2;
  color: #991b1b;
  font-size: 1.1rem;
  font-weight: 900;
  line-height: 1;
}
.delete-row-btn:hover { border-color: #f87171; background: #fecaca; }
.day-comments { margin-top: .6rem; }
.day-comments textarea { min-height: 3rem; }

/* --- Analyte picker ------------------------------------------------------------------- */
.analyte-group { margin-bottom: .75rem; }
.analyte-group-name { margin: 0 0 .1rem; font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .035em; color: var(--label); }
.analyte-option { margin-top: .35rem; }
.analyte-option.is-blocked { color: var(--muted); }
.analyte-not-offered { margin: .25rem 0; font-size: .9rem; color: var(--muted); }

@media (max-width: 760px) {
  .fold-summary { flex-basis: 100%; order: 3; text-align: left; }
  .day-actions { margin-left: 0; }
}

/* --- Sampler and instruments ------------------------------------------------------- */
.instrument-defaults { align-items: start; }
.instrument-defaults fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.instrument-defaults .segmented-row { display: flex; gap: .5rem; margin-top: .25rem; }
.instrument-defaults .segmented-row label {
  display: inline-flex; align-items: center; gap: .45rem; padding: .6rem .8rem; min-height: 44px;
  border: 1px solid var(--border); border-radius: .7rem; text-transform: none; letter-spacing: 0; font-size: .95rem; color: var(--text);
}
