/* Shared styles for the app pages. */
[hidden] { display: none !important; }
:root {
  --bg: #f5f6f8; --panel: #ffffff; --text: #1c2430; --muted: #5d6878;
  --line: #d8dde5; --accent: #1f5f99; --warn-bg: #fff4e0; --warn: #8a5300;
  --key-bg: #eef4fa;
  --locked-bg: #f2f2f2; --ignored: #9c9c9c;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181e; --panel: #1d232b; --text: #e6eaf0; --muted: #9aa5b4;
    --line: #313a46; --accent: #7fb4e6; --warn-bg: #3a2c12; --warn: #f0c070;
    --key-bg: #1f2c3a;
    --locked-bg: #262b33; --ignored: #7d8794;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; padding: 24px 16px 48px; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}
main { max-width: 980px; margin: 0 auto; }
h1 { font-size: 1.35rem; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .grid { grid-template-columns: 1fr; } }
section {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px;
}
h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 12px; }
label { display: block; font-weight: 600; margin: 12px 0 4px; }
label:first-of-type { margin-top: 0; }
.hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
select, input {
  width: 100%; padding: 8px 10px; font: inherit; color: inherit; background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row label { margin-top: 12px; }
.computed { margin-top: 12px; padding: 8px 10px; background: var(--key-bg); border-radius: 6px; }
.computed b { font-variant-numeric: tabular-nums; }
details { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
summary { cursor: pointer; font-weight: 600; }
.vessel-info { color: var(--muted); font-size: .85rem; margin-top: 6px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
td { padding: 7px 0; border-bottom: 1px solid var(--line); }
td:last-child { text-align: right; font-weight: 600; }
td .unit { color: var(--muted); font-weight: 400; margin-left: 4px; }
tr.key td { font-size: 1.1rem; }
tr.key td:last-child { color: var(--accent); }
.working td { padding: 4px 0; font-size: .88rem; }
.working td:last-child { font-weight: 400; }
.msg { margin-top: 12px; padding: 8px 10px; border-radius: 6px; background: var(--warn-bg); color: var(--warn); }
.msg:empty { display: none; }
footer { margin-top: 20px; color: var(--muted); font-size: .8rem; }

/* Navigation between pages */
.nav { margin: -12px 0 16px; }
.nav a { color: var(--accent); }

/* Survey page */
main.wide { max-width: 1400px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0 16px; }
.fields label { margin-top: 12px; }
.fields .computed { margin-top: 12px; align-self: end; }
section + section { margin-top: 16px; }
.table-wrap { overflow-x: auto; }
table.survey { min-width: 1100px; }
table.survey th {
  font-size: .75rem; font-weight: 600; color: var(--muted); text-align: center;
  padding: 4px 4px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.survey th.group { border-bottom: 2px solid var(--line); text-transform: uppercase; letter-spacing: .05em; }
table.survey td { padding: 3px 4px; text-align: right; font-weight: 400; white-space: nowrap; }
table.survey td.tank { text-align: left; font-weight: 600; }
table.survey td.tank .hint { display: block; font-weight: 400; font-size: .75rem; }
table.survey td.out { font-variant-numeric: tabular-nums; }
table.survey td.out.strong { font-weight: 600; }
table.survey td.oor { color: var(--warn); font-weight: 600; }
table.survey input { width: 6.2em; padding: 4px 6px; text-align: right; }
table.survey tfoot td { border-top: 2px solid var(--line); border-bottom: 0; font-weight: 600; }
.actions { margin-top: 16px; display: flex; gap: 12px; align-items: center; }
button {
  font: inherit; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); cursor: pointer;
}
.saved-note { color: var(--muted); font-size: .85rem; }
table.survey.recon { min-width: 760px; }
table.survey td.status { text-align: left; font-weight: 600; }
table.survey td.ok { color: var(--accent); }
.flags { margin: 8px 0 0; padding: 8px 10px; border-radius: 6px; background: var(--warn-bg); color: var(--warn); }
.flags.none { background: var(--key-bg); color: var(--text); }

/* Numeric fields: rejected text and the message bar */
input.invalid { border-color: var(--warn); background: var(--warn-bg); color: var(--warn); }
.input-errors {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  max-width: 980px; margin: 0 auto; padding: 10px 12px; border-radius: 6px; z-index: 10;
  background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15); font-weight: 600;
}

/* Manual m³ fields: locked in AUTO; ignored values as SURVEY INPUT R:S (grey, italic, struck through) */
input.locked { background: var(--locked-bg); color: var(--muted); cursor: not-allowed; }
input.ignored { color: var(--ignored); font-style: italic; text-decoration: line-through; }
.used-badge {
  display: inline-block; margin-left: 4px; padding: 0 4px; border-radius: 3px;
  font-size: .7rem; font-weight: 700; letter-spacing: .04em;
  color: var(--panel); background: var(--accent); vertical-align: middle;
}
td.out .hint { display: block; white-space: normal; font-size: .72rem; font-weight: 400; max-width: 10em; margin-left: auto; }

/* Report details on the survey page */
h3 { font-size: .85rem; margin: 18px 0 0; color: var(--muted); }
textarea {
  width: 100%; padding: 8px 10px; font: inherit; color: inherit; background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; resize: vertical;
}
.pdf-warning { color: var(--warn); font-weight: 600; }

/* Incomplete totals: note under the totals and in the reconciliation status */
table.survey td.incomplete-note { text-align: left; white-space: normal; font-weight: 600; padding-top: 6px; }
table.survey tfoot tr.incomplete-row td { border-top: 0; }
table.survey td.status .hint { max-width: 26em; margin-left: 0; text-align: left; }

/* Under a PDF button: saved file, "Open to view / print", "Save PDF" link */
button.open-view { font-size: .85rem; padding: 3px 10px; margin: 4px 0; }
a.save-pdf { font-weight: 600; color: var(--accent); }

/* Field opened from a dashboard warning (J6) */
input.jump-target { outline: 3px solid var(--warn); outline-offset: 1px; }
