/* styles.css — Biofouling Compliance Copilot. Mobile-first, no external CDNs. */

:root {
  --bg: #0f1720;
  --panel: #ffffff;
  --ink: #14202b;
  --muted: #5a6b7a;
  --line: #d8e0e7;
  --brand: #0a5c7a;
  --brand-dark: #073f55;
  --accent: #0a7d6f;
  --warn-bg: #fff4e0;
  --warn-ink: #6b4a08;
  --warn-line: #e9c46a;
  --low: #1b7f4b;
  --low-bg: #e7f6ee;
  --med: #b5740a;
  --med-bg: #fdf3e0;
  --high: #b3261e;
  --high-bg: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 32, 43, 0.12), 0 4px 16px rgba(16, 32, 43, 0.06);
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #eef3f6 0%, #e3eaef 100%);
  line-height: 1.5;
}

a { color: var(--brand); }

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 16px 64px;
}

/* ---- Header + persistent disclaimer ---- */
header.site {
  background: var(--brand-dark);
  color: #eaf3f7;
  border-bottom: 3px solid var(--accent);
}
header.site .inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 18px 16px 14px;
}
header.site h1 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: 0.2px;
}
header.site .tagline {
  margin: 4px 0 0;
  font-size: 0.92rem;
  color: #b9d4df;
}
.disclaimer-banner {
  background: var(--warn-bg);
  color: var(--warn-ink);
  border-bottom: 1px solid var(--warn-line);
  font-size: 0.86rem;
}
.disclaimer-banner .inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 8px 16px;
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.disclaimer-banner strong { white-space: nowrap; }

/* ---- Panels ---- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-top: 20px;
}
.panel > h2 {
  margin: 0 0 4px;
  font-size: 1.15rem;
  color: var(--brand-dark);
}
.panel > .sub {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---- Form ---- */
form .grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 720px) {
  form .grid { grid-template-columns: 1fr 1fr; }
  form .grid .full { grid-column: 1 / -1; }
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-weight: 600; font-size: 0.86rem; color: var(--ink); }
.field .hint { font-size: 0.78rem; color: var(--muted); }
.field input[type="text"],
.field input[type="number"],
.field input[type="datetime-local"],
.field select,
.field textarea {
  font: inherit;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
  color: var(--ink);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-color: var(--brand);
}
.field textarea { min-height: 64px; resize: vertical; }
.checkbox-row { flex-direction: row; align-items: center; gap: 8px; }
.checkbox-row label { font-weight: 600; }

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 14px 4px;
  margin: 0 0 6px;
}
fieldset legend {
  font-weight: 700;
  color: var(--brand-dark);
  padding: 0 6px;
  font-size: 0.92rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 18px;
}
button {
  font: inherit;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 16px;
  cursor: pointer;
}
button.primary { background: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-dark); }
button.primary:disabled { background: #8fb4c2; cursor: progress; }
button.secondary { background: #eef4f7; color: var(--brand-dark); border-color: var(--line); }
button.secondary:hover { background: #e2edf2; }

.mode-pill {
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #eef4f7;
  color: var(--muted);
}
.mode-pill.live { background: var(--low-bg); color: var(--low); border-color: #bfe3cd; }
.mode-pill.mock { background: var(--med-bg); color: var(--med); border-color: var(--warn-line); }

/* ---- Error state ---- */
.error-box {
  margin-top: 16px;
  border: 1px solid #f0b4af;
  background: var(--high-bg);
  color: var(--high);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.9rem;
}

/* ---- DRAFT marker ---- */
.draft-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--high);
  background: var(--high-bg);
  border: 1px solid #f0b4af;
  border-radius: 4px;
  padding: 2px 7px;
  vertical-align: middle;
  margin-left: 8px;
}

/* ---- Risk gauge / band ---- */
.risk-head {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
}
.gauge {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  flex: 0 0 auto;
  background: conic-gradient(var(--gauge-color) calc(var(--score) * 1%), #e7edf1 0);
}
.gauge::before {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: #fff;
}
.gauge .num {
  position: relative;
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--gauge-color);
  line-height: 1;
}
.gauge .den { position: relative; font-size: 0.8rem; color: var(--muted); }
.gauge .gauge-inner { position: relative; text-align: center; }

.band-block { flex: 1 1 240px; }
.band-pill {
  display: inline-block;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.95rem;
}
.band-LOW { background: var(--low-bg); color: var(--low); border: 1px solid #bfe3cd; }
.band-MEDIUM { background: var(--med-bg); color: var(--med); border: 1px solid var(--warn-line); }
.band-HIGH { background: var(--high-bg); color: var(--high); border: 1px solid #f0b4af; }
.gauge.band-LOW { --gauge-color: var(--low); }
.gauge.band-MEDIUM { --gauge-color: var(--med); }
.gauge.band-HIGH { --gauge-color: var(--high); }

.likelihood { margin: 8px 0 0; color: var(--ink); font-size: 0.92rem; }
.narrative { margin-top: 14px; }
.narrative p { margin: 0; }

/* ---- Missing inputs callout ---- */
.missing-callout {
  margin-top: 14px;
  border: 1px solid var(--warn-line);
  background: var(--warn-bg);
  color: var(--warn-ink);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.88rem;
}
.missing-callout ul { margin: 6px 0 0; padding-left: 20px; }

/* ---- Driver table ---- */
.table-scroll { overflow-x: auto; margin-top: 14px; }
table.drivers {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  min-width: 640px;
}
table.drivers th,
table.drivers td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.drivers thead th {
  background: #f2f7f9;
  color: var(--brand-dark);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
table.drivers td.num, table.drivers th.num { text-align: right; white-space: nowrap; }
.dq {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.dq-high { background: var(--low-bg); color: var(--low); }
.dq-medium { background: #eaf1f6; color: var(--brand-dark); }
.dq-low { background: var(--med-bg); color: var(--med); }
.dq-missing { background: var(--high-bg); color: var(--high); }
.driver-comment { color: var(--muted); margin-top: 4px; font-size: 0.82rem; }

/* ---- Declaration ---- */
.practice-card {
  border: 1px solid var(--line);
  background: #f6fafb;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.practice-card .label { font-weight: 700; color: var(--brand-dark); }
.practice-card .basis { color: var(--muted); font-size: 0.86rem; margin-top: 4px; }
.practice-card .key { font-family: var(--mono); font-size: 0.74rem; color: var(--muted); }

/* "Meets none of the three" elevated-risk outcome — visually distinct from a
   normal endorsed practice and from the hallucinated-key manual-review state. */
.practice-card.non-demonstrated {
  background: var(--high-bg);
  border-color: #f0b4af;
}
.practice-card.non-demonstrated .label { color: var(--high); }
/* Hallucinated / unknown key: amber "needs a human" accent. */
.practice-card.manual-review {
  background: #fff7e6;
  border-color: #f0d28a;
}

textarea.decl {
  width: 100%;
  min-height: 220px;
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.5;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
  color: var(--ink);
  resize: vertical;
}

.list-block { margin-top: 14px; }
.list-block h4 { margin: 0 0 6px; font-size: 0.9rem; color: var(--brand-dark); }
.list-block ul { margin: 0; padding-left: 20px; font-size: 0.88rem; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-list .tag {
  font-family: var(--mono);
  font-size: 0.76rem;
  background: #eef4f7;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 8px;
}

/* ---- Citations ---- */
table.cites { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-top: 6px; }
table.cites th, table.cites td {
  text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top;
}
table.cites thead th { background: #f2f7f9; color: var(--brand-dark); font-size: 0.76rem; text-transform: uppercase; }
.src-ref { font-family: var(--mono); font-size: 0.78rem; }
.src-none { color: var(--high); font-weight: 700; font-size: 0.78rem; }

/* ---- Cleaning record ---- */
.record-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 6px;
}
@media (min-width: 640px) {
  .record-grid { grid-template-columns: 260px 1fr; }
}
.record-grid .rk, .record-grid .rv {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 0.86rem;
}
.record-grid .rk { background: #f6fafb; font-weight: 600; color: var(--brand-dark); }
.record-grid .rv { background: #fff; }
.record-grid .rv.todo { color: var(--med); font-style: italic; }

.confidence {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--muted);
}
.confidence .conf-pill {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-size: 0.74rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
}
.confidence .conf-high { background: var(--low-bg); color: var(--low); }
.confidence .conf-medium { background: var(--med-bg); color: var(--med); }
.confidence .conf-low { background: var(--high-bg); color: var(--high); }

.caveats-block { margin-top: 16px; }
.caveats-block ul { margin: 6px 0 0; padding-left: 20px; font-size: 0.86rem; color: var(--ink); }

.meta-manifest {
  margin-top: 18px;
  font-size: 0.76rem;
  color: var(--muted);
  font-family: var(--mono);
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}

.section-actions { margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap; }

/* Required-field marker + invalid highlight (form submit guard). */
.req { color: var(--high); font-weight: 700; }
.input-error,
.input-error:focus {
  border-color: var(--high) !important;
  box-shadow: 0 0 0 3px var(--high-bg) !important;
  outline: none;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---- Print: only the cleaning record, cleanly ---- */
@media print {
  body { background: #fff; color: #000; }
  header.site, .disclaimer-banner, .enrich-hero, #intake-panel, #risk-panel,
  #declaration-panel, #caveats-panel, .site-footer, .section-actions, .actions,
  .mode-pill, #error-box { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  #cleaning-panel {
    box-shadow: none;
    border: none;
    margin: 0;
    padding: 0;
  }
  #cleaning-panel .draft-tag {
    color: #000;
    border: 1px solid #000;
    background: #fff;
  }
  .record-grid { border: 1px solid #000; }
  .record-grid .rk, .record-grid .rv { border-bottom: 1px solid #888; }
  .record-grid .rk { background: #f0f0f0; }
  .print-only { display: block !important; }
  .print-footer {
    margin-top: 14px;
    padding-top: 8px;
    border-top: 1px solid #000;
    font-size: 0.72rem;
    color: #333;
  }
  @page { margin: 18mm; }
}
.print-only { display: none; }

.site-footer {
  margin-top: 28px;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

/* ---- Data-enrichment: hero callout, IMO auto-fill, estimate badges ---- */
/* Positive, on-brand (accent/teal) callout — distinct from the amber warning
   banner. It advertises the auto-fill capability while keeping the honest
   "estimates for review" qualifier the whole tool is built around. */
.enrich-hero {
  background: linear-gradient(180deg, #e7f6f1 0%, #dcefe9 100%);
  border-bottom: 1px solid #b7e0d4;
  color: var(--brand-dark);
}
.enrich-hero .inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.enrich-hero-badge {
  flex: 0 0 auto;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  margin-top: 2px;
}
.enrich-hero-body { font-size: 0.9rem; line-height: 1.45; }
.enrich-hero-body strong { color: var(--accent); }
.enrich-hero-qual { display: block; margin-top: 4px; font-size: 0.8rem; color: var(--muted); }

/* IMO field + "Auto-fill from AIS" button row */
.imo-row { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.imo-row input { flex: 1 1 220px; }
.enrich-btn { white-space: nowrap; flex: 0 0 auto; }

/* Provenance / status line under the IMO field */
.enrich-note {
  margin: 8px 0 0;
  font-size: 0.82rem;
  border-radius: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #f2f7f9;
  color: var(--ink);
}
.enrich-note.info { background: var(--low-bg); border-color: #bfe3cd; color: var(--brand-dark); }
.enrich-note.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }

/* "estimated — confirm" badge appended to each enriched field's label */
.est-badge {
  display: inline-block;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--accent);
  background: #e8f4f0;
  border: 1px solid #bfe0d6;
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 8px;
  vertical-align: middle;
}

/* MARS PAR XML generator — button block + per-field provenance checklist. */
.mars-xml-block .sub { color: var(--muted); font-size: 0.86rem; margin: 0 0 4px; }
.mars-xml-notes { margin-top: 12px; }
.mars-xml-summary { font-size: 0.86rem; margin: 0 0 8px; }
.mars-xml-err {
  background: var(--high-bg);
  border: 1px solid #f0b4af;
  color: var(--high);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.86rem;
  margin: 0;
}
table.mars-xml-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
table.mars-xml-table th,
table.mars-xml-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.mars-xml-table thead th {
  background: #f2f7f9;
  color: var(--brand-dark);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.mars-pill {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 1px 9px;
  white-space: nowrap;
}
.mars-set { background: var(--low-bg); color: var(--low); }
.mars-agent { background: #eaf1f6; color: var(--brand-dark); }
.mars-hint { background: var(--med-bg); color: var(--med); }
.mars-val { font-family: var(--mono); font-size: 0.78rem; color: var(--brand-dark); }
.mars-why { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }
