/*
 * FieldICS screen styles.
 * A working console: graphite chrome, an incident strip with the live clock,
 * grouped navigation, and forms laid out as bordered panels with header bars.
 * Printed forms are styled separately at the end of this file.
 */

@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-style: normal; font-display: swap; src: url("fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-style: normal; font-display: swap; src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans Condensed"; font-weight: 500; font-style: normal; font-display: swap; src: url("fonts/ibm-plex-sans-condensed-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans Condensed"; font-weight: 600; font-style: normal; font-display: swap; src: url("fonts/ibm-plex-sans-condensed-latin-600-normal.woff2") format("woff2"); }

:root {
  /* Chrome: the top bar and incident strip. */
  --chrome: #1c2329;
  --chrome-2: #252e36;
  --chrome-line: #36424c;
  --chrome-text: #e8edf1;
  --chrome-muted: #a3b0ba;
  /* Work area. */
  --bg: #eceff1;
  --card: #ffffff;
  --soft: #f5f7f8;
  --side: #f7f9fa;
  --text: #172026;
  --muted: #56636d;
  --line: #d2d8dd;
  --line-strong: #a9b3bb;
  --hover: #e8edf0;
  --hover-line: #8d98a1;
  --text-2: #2c3740;
  --tag-bg: #e7ecef;
  --tag-ink: #34424c;
  --correction-bg: #fffcf3;
  --bar-bg: rgba(255, 255, 255, 0.97);
  /* One action color: CompliAid teal, brightened for screens. */
  --action: #0a6b73;
  --action-dark: #08575e;
  --action-tint: #e1eff0;
  --action-ink: #075a61;
  /* Status. */
  --ok: #1e7a46;
  --ok-bg: #e4f3ea;
  --warn: #8f5b00;
  --warn-bg: #fff4dc;
  --warn-line: #e6c675;
  --warn-ink: #4d3600;
  --info-bg: #fff7e3;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --focus: #1a66d2;
  --exercise: #6b3fa0;
  --exercise-bg: #f2ebfb;
  --exercise-ink: #3c1f63;
  --r-sm: 4px;
  --r: 6px;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-cond: "IBM Plex Sans Condensed", "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  /* Control sizes: comfortable for fingers, tighter with a mouse (below). */
  --ctl: 44px;
  --ctl-sm: 36px;
  --fs: 16px;
}

@media (pointer: fine) {
  :root { --ctl: 36px; --ctl-sm: 30px; --fs: 14.5px; }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs)/1.45 var(--font);
  font-feature-settings: "tnum" 0;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; }
h2 { font-size: 1.12rem; margin-bottom: 8px; letter-spacing: -0.005em; }
h3 { font-size: 1rem; }
p { margin: 0 0 10px; }
a { color: var(--action-ink); }

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

.skip {
  position: absolute;
  left: -999px;
  top: 8px;
  background: #fff;
  color: var(--action-ink);
  padding: 8px 12px;
  border-radius: var(--r-sm);
  z-index: 100;
}
.skip:focus { left: 8px; }

/* ---------- top bar ---------- */

.topbar {
  background: var(--chrome);
  color: var(--chrome-text);
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { border-radius: 5px; flex: 0 0 auto; display: block; }
.brand h1 { font-size: 1.02rem; font-weight: 600; letter-spacing: 0.01em; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar .btn-quiet {
  color: var(--chrome-text);
  border-color: var(--chrome-line);
  background: transparent;
  min-height: var(--ctl-sm);
  font-size: 0.88rem;
}
.topbar .btn-quiet:hover { background: var(--chrome-2); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8rem;
  color: var(--chrome-muted);
  white-space: nowrap;
}
.chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--chrome-muted);
  flex: 0 0 auto;
}
.chip.ok::before { background: #3fbf7f; }
.chip.warn::before { background: #f0b43c; }
.chip.warn { color: #f3d48f; }
@media (max-width: 560px) {
  .chip { font-size: 0; gap: 0; }
  .chip::before { width: 10px; height: 10px; }
}

/* ---------- incident strip ---------- */

.context {
  background: var(--chrome-2);
  color: var(--chrome-text);
  border-top: 1px solid var(--chrome-line);
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 0;
}
.is-exercise .context { box-shadow: inset 0 3px 0 var(--exercise); }

.bar { flex: 1 1 520px; display: flex; flex-wrap: wrap; min-width: 0; padding: 6px 8px 8px 16px; gap: 6px 20px; }
.bar-row { display: flex; align-items: center; gap: 4px 10px; flex: 1 1 300px; min-width: 0; }
.bar-label {
  font-family: var(--font-cond);
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--chrome-muted);
  white-space: nowrap;
}
.bar-controls { display: flex; align-items: center; gap: 6px; flex: 1 1 auto; min-width: 0; }
.bar-controls select {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  min-height: var(--ctl-sm);
  padding: 4px 28px 4px 10px;
  background-color: var(--chrome);
  color: var(--chrome-text);
  border-color: var(--chrome-line);
  font-family: var(--font-cond);
  font-weight: 600;
  font-size: 0.95rem;
}
.bar-controls .btn {
  flex: 0 0 auto;
  min-height: var(--ctl-sm);
  background: transparent;
  color: var(--chrome-text);
  border-color: var(--chrome-line);
}
.bar-controls .btn:hover { background: var(--chrome); }
.bar-controls .grow { flex: 1 1 auto; margin: 0; color: var(--chrome-muted); }

.ops-clock {
  flex: 0 0 auto;
  margin-left: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  padding: 6px 16px;
  border-left: 1px solid var(--chrome-line);
  font-family: var(--font-cond);
  line-height: 1.15;
}
.ops-time { font-size: 1.45rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.ops-sub { font-size: 0.78rem; color: var(--chrome-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 719px) {
  .bar { padding: 6px 12px 4px; flex-basis: 100%; }
  .bar-row { flex-basis: 100%; }
  .bar-label { width: 52px; white-space: normal; line-height: 1.1; }
  .ops-clock {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    margin: 0;
    padding: 2px 12px 7px;
    border-left: 0;
  }
  .ops-time { font-size: 1.05rem; }
}

/* ---------- banners and notices ---------- */

.banner {
  background: var(--warn-bg);
  color: var(--warn-ink);
  padding: 9px 16px;
  font-weight: 500;
  border-bottom: 1px solid var(--warn-line);
}
.banner-info { background: var(--info-bg); }
.banner-info p { margin: 0 0 8px; font-weight: 600; }

.notices { display: grid; gap: 8px; padding: 12px 12px 0; }
.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 9px 12px;
  border: 1px solid var(--warn-line);
  border-left: 4px solid var(--warn);
  border-radius: var(--r-sm);
  background: var(--warn-bg);
  color: var(--warn-ink);
}
.notice-exercise { background: var(--exercise-bg); border-color: #cdb8ea; border-left-color: var(--exercise); color: var(--exercise-ink); justify-content: flex-start; }

/* ---------- shell: sidebar and work area ---------- */

.shell { display: block; }
/* No incident open (first run, locked): no strip, no sidebar. */
.context:has(#incidentBar[hidden]) { display: none; }
.side:has(#nav[hidden]) { display: none; }
.work { min-width: 0; }
main { padding: 12px; }
/* Room to scroll the last item clear of the Log it button. */
body:has(#quickLogBtn:not([hidden])) main { padding-bottom: 88px; }

.side {
  position: sticky;
  top: 0;
  z-index: 25;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

/* Phone and tablet: the navigation is a scrolling strip of tabs. */
.tabs {
  display: flex;
  overflow-x: auto;
  padding: 0 8px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.nav-group { display: none; }
.tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 46px;
  padding: 0 10px;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.92rem;
  text-decoration: none;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-current="page"] { color: var(--text); border-bottom-color: var(--action); font-weight: 600; }
.nav-code {
  font-family: var(--font-cond);
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--action-ink);
  font-variant-numeric: tabular-nums;
}
.badge {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--warn);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}

/* Second-level tabs (cost types): a segmented control. */
.subtabs {
  display: flex;
  max-width: 100%;
  width: fit-content;
  overflow-x: auto;
  margin: 0 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--card);
  scrollbar-width: none;
}
.subtabs::-webkit-scrollbar { display: none; }
.subtab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--ctl-sm);
  padding: 0 12px;
  border-right: 1px solid var(--line);
  color: var(--text-2);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.subtab:last-child { border-right: 0; }
.subtab:hover { background: var(--soft); }
.subtab[aria-current="page"] { background: var(--action); color: #fff; }
.subtab .count {
  font-size: 0.78rem;
  color: inherit;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

/* Laptop and desktop: a fixed sidebar, grouped by ICS function. */
@media (min-width: 1024px) {
  .shell { display: grid; grid-template-columns: 228px minmax(0, 1fr); align-items: start; }
  .shell:has(#nav[hidden]) { display: block; }
  .shell:has(#nav[hidden]) main, .shell:has(#nav[hidden]) .foot { margin: 0 auto; }
  .side {
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: var(--side);
    border-bottom: 0;
    border-right: 1px solid var(--line);
  }
  .tabs { display: block; padding: 10px 0 24px; overflow: visible; }
  .nav-group {
    display: block;
    padding: 14px 18px 4px;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--muted);
  }
  .nav-group:first-child { padding-top: 4px; }
  .tab {
    display: grid;
    grid-template-columns: 46px 1fr auto;
    align-items: center;
    min-height: 34px;
    padding: 0 12px 0 15px;
    border-bottom: 0;
    border-left: 3px solid transparent;
    font-size: 0.9rem;
  }
  .tab:hover { background: var(--hover); }
  .tab[aria-current="page"] { background: var(--action-tint); border-left-color: var(--action); }
  .tab .nav-name:only-child { grid-column: 1 / 3; }
  main { padding: 18px 24px; max-width: 1180px; }
  .notices { padding: 18px 24px 0; max-width: 1180px; }
}

/* ---------- panels ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 12px; }
.row.space { justify-content: space-between; margin-top: 12px; flex-wrap: wrap; }
.tools { margin: 12px 0 0; }
.filters { margin: 10px 0; }
.filters select { width: auto; min-width: 160px; flex: 1 1 160px; }

.grid { display: grid; gap: 0 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .grid.two { grid-template-columns: 1fr 1fr; }
  .grid.three { grid-template-columns: 1.2fr 1fr 1fr; }
}

/* ---------- controls ---------- */

.field { margin: 0 0 12px; min-width: 0; }
.field label, .field legend { display: block; font-weight: 500; font-size: 0.86rem; color: var(--text-2); margin-bottom: 4px; padding: 0; }
fieldset.plain { border: 0; padding: 0; margin: 0 0 12px; min-width: 0; }
details.field summary { cursor: pointer; font-weight: 600; color: var(--action-ink); margin-bottom: 8px; }

input[type="text"], input[type="password"], input[type="search"], input[type="datetime-local"], input[type="date"], input[type="time"], select, textarea {
  width: 100%;
  min-height: var(--ctl);
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: max(16px, 1em);
}
@media (pointer: fine) {
  input[type="text"], input[type="password"], input[type="search"], input[type="datetime-local"], input[type="date"], input[type="time"], select, textarea { font-size: 1em; }
}
input:hover, select:hover, textarea:hover { border-color: var(--hover-line); }
textarea { resize: vertical; min-height: 72px; line-height: 1.45; }
input[aria-invalid="true"] { border-color: var(--danger); background: #fff8f7; }
input.num { font-variant-numeric: tabular-nums; }

input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--focus); }

.with-btn { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.with-btn input { flex: 1 1 190px; min-width: 0; }
.affix { display: flex; align-items: center; gap: 6px; }
.affix span { color: var(--muted); font-weight: 500; }
.affix input { flex: 1 1 auto; min-width: 0; }

.choice { display: flex; gap: 8px; align-items: flex-start; font-weight: 400 !important; margin-bottom: 6px !important; }
.choice input { margin-top: 4px; accent-color: var(--action); }
.check { display: inline-flex; align-items: center; gap: 7px; font-weight: 400 !important; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; flex: 0 0 auto; accent-color: var(--action); }
.check.small { font-size: 0.86rem; color: var(--muted); }
.check.top { align-items: flex-start; }
.check.top input { margin-top: 2px; }
.checks-row { display: flex; flex-wrap: wrap; gap: 8px 18px; }

.btn {
  min-height: var(--ctl);
  padding: 0 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}
.btn:hover { background: var(--soft); border-color: var(--hover-line); }
.btn:active { background: var(--hover); }
.btn-primary { background: var(--action); color: #fff; border-color: var(--action); }
.btn-primary:hover { background: var(--action-dark); border-color: var(--action-dark); }
.btn-primary:active { background: var(--action-dark); }
.btn-quiet { border-color: var(--line); color: var(--text-2); }
.btn-danger { color: var(--danger); border-color: #e3a19b; }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn-small { min-height: var(--ctl-sm); padding: 0 10px; font-size: 0.86rem; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-wide { width: 100%; justify-content: flex-start; text-align: left; white-space: normal; padding-top: 8px; padding-bottom: 8px; }

.hint { color: var(--muted); font-size: 0.86rem; margin: 4px 0 0; }
.error { color: var(--danger); font-weight: 500; font-size: 0.9rem; margin: 8px 0 0; }
.field-error { color: var(--danger); font-size: 0.82rem; margin: 4px 0 0; }
.count { font-weight: 400; color: var(--muted); font-size: 0.88rem; }
.warn-text { color: var(--warn); font-weight: 600; }

/* ---------- form editor ---------- */

.view-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.view-head h2 { margin-bottom: 4px; }
.auto-info { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 10px 0 0; padding-top: 10px; border-top: 1px solid var(--line); }
.auto-info div { min-width: 0; }
.auto-info dt { font-size: 0.78rem; color: var(--muted); }
.auto-info dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.saved-line { margin-top: 8px; }

.conflict-note {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-left: 4px solid var(--warn);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  margin: 10px 0 0;
  color: var(--warn-ink);
}
.conflict-note p { margin: 0 0 8px; }
.conflict-note p:last-child { margin-bottom: 0; }

.editor { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) {
  .editor { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .editor > * { grid-column: 1 / -1; }
  .editor > .block.half { grid-column: auto; }
}
.block {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 0 14px 2px;
  min-width: 0;
  scroll-margin-top: 60px;
}
/* Each form block opens with a header bar carrying its ICS block number and name. */
.block-title {
  margin: 0 -14px 12px;
  padding: 8px 14px;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
  border-radius: var(--r) var(--r) 0 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}
.block > .hint { margin: -4px 0 12px; }
.section-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  margin: 10px 0 -4px;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--line);
}
.block-grid {
  display: grid;
  gap: 0 14px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
}
.block-grid > .kind-textarea,
.block-grid > .kind-rows,
.block-grid > .kind-checks,
.block-grid > .kind-image,
.block-grid > .kind-images { grid-column: 1 / -1; }

.rows-list { margin: 2px 0 8px; }
.row-card {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 0 10px;
  margin-bottom: 8px;
  background: var(--card);
}
.row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 -10px 10px;
  padding: 4px 6px 4px 10px;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
}
.row-num { font-family: var(--font-cond); font-weight: 600; font-size: 0.86rem; color: var(--muted); }
.row-tools { display: flex; gap: 4px; flex-wrap: wrap; }
.row-tools .btn { min-height: 28px; padding: 0 8px; font-size: 0.8rem; border-color: transparent; background: transparent; color: var(--muted); }
.row-tools .btn:hover { background: var(--hover); color: var(--text); }
.row-grid {
  display: grid;
  gap: 0 10px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr));
}
.row-grid > .kind-textarea { grid-column: 1 / -1; }
.row-grid .field label { font-size: 0.8rem; }

.image-field .thumb {
  display: block;
  max-width: 100%;
  max-height: 340px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  margin-bottom: 8px;
  background: #fff;
}

.checkbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.checkbar select { width: auto; flex: 1 1 220px; min-width: 0; max-width: 100%; min-height: var(--ctl-sm); }
.block.flash { box-shadow: 0 0 0 2px var(--focus); transition: box-shadow 0.3s; }
.block:focus { outline: none; }

.actionbar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 12px -12px 0;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--bar-bg);
  border-top: 1px solid var(--line);
  box-shadow: 0 -1px 0 rgba(23, 32, 38, 0.03);
}
@media (min-width: 1024px) {
  .actionbar { margin: 16px -24px 0; padding-left: 24px; padding-right: 24px; }
}
.dirty { color: var(--warn); font-weight: 500; font-size: 0.86rem; }
.form-error { margin: 10px 2px; }

/* ---------- record lists: dense rows in one bordered table ---------- */

.items {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--card);
  overflow: hidden;
}
.items:empty { display: none; }
.items li { position: relative; }
.items li + li { border-top: 1px solid var(--line); }
.item {
  display: block;
  padding: 10px 14px 10px 13px;
  border-left: 3px solid transparent;
  color: var(--text);
  text-decoration: none;
  background: transparent;
}
a.item:hover, button.item:hover { background: var(--soft); }
.item.needs { border-left-color: var(--warn); }
.item.donated { border-left-color: var(--ok); }
.item.is-deleted { opacity: 0.55; }
.item.is-deleted .item-title { text-decoration: line-through; }
.item-top { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.item-title { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.item-line { display: block; font-size: 0.86rem; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.items li .item-action { position: absolute; right: 12px; top: 9px; }
.items li .item { padding-right: 120px; }
.items li .item:only-child { padding-right: 14px; }
/* Phones: the action sits under the row, on the left, clear of the Log it button. */
@media (max-width: 599px) {
  .items li .item-action { position: static; margin: 0 0 10px 16px; }
  .items li .item { padding-right: 14px; }
}
.rate-item { width: 100%; text-align: left; font: inherit; cursor: pointer; border: 0; border-left: 3px solid transparent; }
.rate-list { max-height: 55vh; overflow: auto; }
.total-line { font-weight: 600; margin: 12px 0 0; font-variant-numeric: tabular-nums; }

.tag {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 500;
  padding: 1px 7px;
  border-radius: var(--r-sm);
  background: var(--tag-bg);
  color: var(--tag-ink);
  margin-right: 4px;
  white-space: nowrap;
}
.tag.warn { background: var(--warn-bg); color: var(--warn); }

.table-wrap { overflow-x: auto; margin: 10px 0; border: 1px solid var(--line); border-radius: var(--r-sm); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.9rem; background: var(--card); }
table.data th, table.data td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-family: var(--font-cond); font-weight: 600; font-size: 0.82rem; color: var(--muted); background: var(--soft); }
table.data tr:last-child td { border-bottom: 0; }
table.data td:first-child { min-width: 7em; }
@media (max-width: 599px) {
  table.data th, table.data td { padding: 7px 6px; }
  table.data td:first-child { min-width: 5.6em; }
  table.data th { font-size: 0.78rem; }
}
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr.total td { font-weight: 600; background: var(--soft); }
.small-title { font-size: 0.95rem; margin: 16px 0 6px; }

/* ---------- activity log ---------- */

.correct-banner {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-left: 4px solid var(--warn);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  margin-bottom: 12px;
}
.correct-banner p { margin: 4px 0 0; }
.log-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.log-head h2 { margin: 0; }
.log-head select { width: auto; min-width: 140px; }
.log { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.log:empty { display: none; }
.entry {
  border-left: 3px solid transparent;
  padding: 10px 14px 10px 13px;
  background: var(--card);
}
.entry + .entry { border-top: 1px solid var(--line); }
.entry.is-correction { border-left-color: var(--warn); background: var(--correction-bg); }
.entry.is-superseded { border-left-color: var(--line-strong); background: var(--soft); color: var(--muted); }
.entry.is-remote { border-left-color: var(--action); }
.entry-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 0.86rem; color: var(--muted); }
.entry-time { font-family: var(--font-cond); font-weight: 600; font-size: 0.95rem; color: var(--text); font-variant-numeric: tabular-nums; }
.entry-text { margin: 4px 0 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.entry-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.8rem; color: var(--muted); }
.entry-foot .btn { min-height: 28px; font-size: 0.8rem; }

/* ---------- notes ---------- */

.note-form { margin: 12px 0 4px; }
.note-form textarea { min-height: 76px; }
.note-form-row { margin-top: 8px; }
.note-form-row select { width: auto; min-width: 140px; flex: 0 1 auto; }
.note-form-row .btn-primary { margin-left: auto; }
.note-filters input[type="search"] { flex: 1 1 220px; width: auto; }
.note-filters select { flex: 0 1 200px; }
.notes { list-style: none; margin: 4px 0 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.notes:empty { display: none; }
.note { padding: 10px 14px 8px 13px; border-left: 3px solid transparent; background: var(--card); }
.note + .note { border-top: 1px solid var(--line); }
.note.is-pinned { border-left-color: var(--action); background: var(--soft); }
.note.is-open { border-left-color: var(--warn); }
.note.is-deleted { opacity: 0.55; }
.note-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 0.84rem; color: var(--muted); }
.note-time { font-family: var(--font-cond); font-weight: 600; font-size: 0.92rem; color: var(--text); font-variant-numeric: tabular-nums; }
.note-text { margin: 5px 0 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-meta { margin: 0 0 4px; font-size: 0.8rem; color: var(--muted); }
.note-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 2px; }
.note-actions .btn { min-height: 28px; font-size: 0.8rem; padding: 0 9px; }
.tag-pin { background: var(--action-tint); color: var(--action-ink); }
.tag-ok { background: var(--ok-bg); color: var(--ok); }

/* Two-way choice shown as one control (Log it: 214 entry or note). */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-sm); overflow: hidden; margin: 0 0 8px; }
.seg-opt { display: inline-flex; align-items: center; gap: 6px; min-height: var(--ctl-sm); padding: 0 14px; cursor: pointer; font-weight: 500; font-size: 0.9rem; color: var(--text-2); }
.seg-opt + .seg-opt { border-left: 1px solid var(--line-strong); }
.seg-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg-opt:has(input:checked) { background: var(--action); color: #fff; }
.seg-opt:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: -2px; }

/* ---------- dialogs ---------- */

dialog {
  width: min(600px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px 20px;
  box-shadow: 0 16px 48px rgba(16, 24, 30, 0.28);
  color: var(--text);
  background: var(--card);
}
dialog.wide { width: min(1000px, calc(100vw - 16px)); }
dialog::backdrop { background: rgba(18, 24, 29, 0.55); }
dialog:not([open]) { display: none; }
dialog h2 { margin-bottom: 14px; font-size: 1.08rem; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: -18px -20px 14px;
  padding: 12px 16px 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--soft);
  position: sticky;
  top: -18px;
  z-index: 2;
}
.panel-head h2 { margin: 0; }

.msg-list { padding-left: 20px; margin: 0 0 10px; }
.msg-list li { margin-bottom: 8px; overflow-wrap: anywhere; }

.cmp-versions { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); margin: 10px 0 4px; }
.cmp-version { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; background: var(--soft); }
.cmp-version .btn { margin-top: 8px; }
.cmp-letter { font-family: var(--font-cond); font-weight: 600; color: var(--action-ink); }
.cmp-field { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 12px 4px; margin: 0 0 10px; min-width: 0; }
.cmp-field legend { font-weight: 600; padding: 0 4px; }
.cmp-option { display: flex; align-items: flex-start; gap: 8px; padding: 7px 2px; border-top: 1px solid var(--line); cursor: pointer; }
.cmp-option:first-of-type { border-top: 0; }
.cmp-option input { width: 18px; height: 18px; margin: 2px 0 0; flex: 0 0 auto; accent-color: var(--action); }
.cmp-tag { flex: 0 0 auto; font-family: var(--font-cond); font-weight: 600; color: var(--action-ink); min-width: 1.2em; }
.cmp-val { white-space: pre-wrap; overflow-wrap: anywhere; font-weight: 400; min-width: 0; }

.history { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r-sm); }
.history li { padding: 10px 12px; }
.history li + li { border-top: 1px solid var(--line); }
.history-meta { font-weight: 600; margin-bottom: 4px; }
.history .row { margin-top: 6px; }

.preview {
  background: #fff;
  border: 1px solid var(--line);
  padding: 12px;
  margin-top: 10px;
  overflow: auto;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(150px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--chrome);
  color: var(--chrome-text);
  padding: 10px 16px;
  border-radius: var(--r);
  border-left: 4px solid var(--action);
  max-width: calc(100vw - 32px);
  font-weight: 500;
  z-index: 60;
  box-shadow: 0 8px 24px rgba(16, 24, 30, 0.3);
}

.welcome p { max-width: 68ch; }

.foot { padding: 6px 12px 28px; color: var(--muted); font-size: 0.8rem; max-width: 1180px; }
.foot p { margin: 0 0 4px; max-width: 90ch; }
@media (min-width: 1024px) { .foot { padding: 6px 24px 28px; } }

/* ---------- Log it ---------- */

.fab {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(86px + env(safe-area-inset-bottom));
  z-index: 40;
  min-height: 48px;
  padding: 0 18px 0 14px;
  border-radius: var(--r);
  border: 1px solid #0e1418;
  background: var(--chrome);
  color: #fff;
  font: inherit;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(16, 24, 30, 0.3);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.fab::before {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: var(--r-sm);
  background: var(--action);
  font-size: 18px;
  line-height: 1;
}
.fab:hover { background: #283139; }
.fab:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

/* ---------- photos ---------- */

.photo-strip { display: grid; gap: 8px; }
.photo-row { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-cell { display: grid; gap: 4px; justify-items: start; }
.photo-thumb {
  width: 108px;
  height: 84px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-row.small .photo-thumb { width: 72px; height: 56px; }
.photo-thumb.missing { cursor: default; padding: 4px; }
.photo-large { display: block; max-width: 100%; max-height: 70vh; margin: 0 auto 8px; border-radius: var(--r-sm); }
.mini-thumb { width: 56px; height: 44px; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line); }
.entry-photos { margin: 0 0 10px; }
.entry .photo-row { margin: 4px 0 6px; }

/* ---------- checks, setup, QR, lock ---------- */

.check-list { list-style: none; margin: 6px 0 12px; padding: 0; border: 1px solid var(--line); border-radius: var(--r-sm); }
.check-list li {
  padding: 8px 12px 8px 11px;
  border-left: 3px solid var(--line-strong);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  justify-content: space-between;
}
.check-list li + li { border-top: 1px solid var(--line); }
.check-list li.lvl-fix { border-left-color: var(--danger); }
.check-list li.lvl-check { border-left-color: var(--warn); }
.ok-note { background: var(--ok-bg); color: var(--ok); padding: 9px 12px; border-left: 4px solid var(--ok); border-radius: var(--r-sm); font-weight: 500; }

.donated-box { border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: var(--r-sm); padding: 8px 12px; margin: 10px 0; }
.plain-list { margin: 6px 0 10px; padding-left: 20px; }
.subcard { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 12px; }
.settings-tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }

.qr-wrap { display: flex; justify-content: center; margin: 10px 0; }
.qr-canvas { width: min(92vw, 520px, 62vh); height: auto; aspect-ratio: 1; background: #fff; border-radius: var(--r-sm); image-rendering: pixelated; }
.qr-video { width: min(100%, 520px); max-height: 55vh; border-radius: var(--r-sm); background: #000; }
.qr-progress { display: flex; flex-wrap: wrap; gap: 3px; margin: 6px 0; }
.qr-part { width: 14px; height: 14px; border-radius: 2px; background: var(--line); }
.qr-part.got { background: var(--ok); }

.lock-card { max-width: 420px; margin: 48px auto; padding: 22px 24px; }
.clock-big { font-family: var(--font-cond); font-size: 2.2rem; font-weight: 600; font-variant-numeric: tabular-nums; margin: 4px 0 8px; }
.out-preview { max-height: 55vh; }
.out-preview .p-doc + .p-doc { margin-top: 18px; padding-top: 18px; border-top: 2px dashed #999; }

/* ---------- text size ---------- */

:root[data-text="large"] { --fs: 17.5px; }
:root[data-text="larger"] { --fs: 19.5px; }
@media (pointer: fine) {
  :root[data-text="large"] { --fs: 16px; }
  :root[data-text="larger"] { --fs: 18px; }
}

/* ---------- night mode ---------- */

:root[data-theme="dark"] {
  --hover: #232b32;
  --hover-line: #5d6973;
  --text-2: #c9d2d8;
  --tag-bg: #26303a;
  --tag-ink: #d5dde3;
  --correction-bg: #231e10;
  --bar-bg: rgba(23, 29, 34, 0.97);
  --chrome: #12171b;
  --chrome-2: #1a2026;
  --chrome-line: #2c353d;
  --bg: #0f1418;
  --card: #171d22;
  --soft: #1d242a;
  --side: #141a1f;
  --text: #e3e8ec;
  --muted: #9ba8b2;
  --line: #2a333b;
  --line-strong: #46525c;
  --action: #0f7a83;
  --action-dark: #0d6d75;
  --action-tint: #16343a;
  --action-ink: #6cc3ca;
  --ok: #7fd3a5;
  --ok-bg: #16301f;
  --warn: #e7b04a;
  --warn-bg: #2f2612;
  --warn-line: #5c4a1e;
  --warn-ink: #f6dfaa;
  --info-bg: #2b2412;
  --danger: #ff9d94;
  --danger-bg: #3a1c1a;
  --focus: #6aa8ff;
  --exercise: #b892ea;
  --exercise-bg: #261b37;
  --exercise-ink: #e3d2fb;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --chrome: #12171b;
    --chrome-2: #1a2026;
    --chrome-line: #2c353d;
    --bg: #0f1418;
    --card: #171d22;
    --soft: #1d242a;
    --side: #141a1f;
    --text: #e3e8ec;
    --muted: #9ba8b2;
    --line: #2a333b;
    --line-strong: #46525c;
    --hover: #232b32;
    --hover-line: #5d6973;
    --text-2: #c9d2d8;
    --tag-bg: #26303a;
    --tag-ink: #d5dde3;
    --correction-bg: #231e10;
    --bar-bg: rgba(23, 29, 34, 0.97);
    --action: #0f7a83;
    --action-dark: #0d6d75;
    --action-tint: #16343a;
    --action-ink: #6cc3ca;
    --ok: #7fd3a5;
    --ok-bg: #16301f;
    --warn: #e7b04a;
    --warn-bg: #2f2612;
    --warn-line: #5c4a1e;
    --warn-ink: #f6dfaa;
    --info-bg: #2b2412;
    --danger: #ff9d94;
    --danger-bg: #3a1c1a;
    --focus: #6aa8ff;
    --exercise: #b892ea;
    --exercise-bg: #261b37;
    --exercise-ink: #e3d2fb;
    color-scheme: dark;
  }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}


/* ---------- version 0.4: flags, assessments, sign-offs, close-out, shared folder ---------- */

/* Phone: the incident strip folds to one line. */
.strip-summary { display: none; }
@media (max-width: 719px) {
  .strip-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 4px 0;
    border: 0;
    background: transparent;
    color: var(--chrome-text);
    font: 600 0.95rem/1.2 var(--font-cond);
    text-align: left;
    cursor: pointer;
  }
  .strip-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .strip-period { flex: 0 0 auto; color: var(--chrome-muted); font-weight: 500; font-variant-numeric: tabular-nums; }
  .strip-caret { flex: 0 0 auto; font-size: 0.78rem; color: var(--chrome-muted); border: 1px solid var(--chrome-line); border-radius: var(--r-sm); padding: 2px 8px; }
  .context:not(.is-open) .bar-row { display: none; }
  .context:not(.is-open) .bar { padding-bottom: 0; }
  .strip-summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
}

.notice-lock { background: var(--danger-bg); border-color: var(--danger); border-left-color: var(--danger); color: var(--text); }
.notice-sync { background: var(--action-tint); border-color: var(--action); border-left-color: var(--action); color: var(--text); }

.warn-note { background: var(--warn-bg); color: var(--warn-ink); padding: 9px 12px; border-left: 4px solid var(--warn); border-radius: var(--r-sm); font-weight: 500; }
.flag-box { border: 1px solid var(--warn-line); border-left: 4px solid var(--warn); border-radius: var(--r-sm); background: var(--warn-bg); color: var(--warn-ink); padding: 8px 12px; margin: 10px 0; }
.flag-box .hint { color: var(--warn-ink); opacity: 0.9; }
.tag-flag { background: var(--warn-bg); color: var(--warn); }

.cost-preview {
  border: 1px solid var(--line);
  border-left: 4px solid var(--action);
  border-radius: var(--r-sm);
  background: var(--card);
  padding: 8px 12px;
  margin: 12px 0 0;
}
.cost-preview p { margin: 0; }
.cost-preview .cost-line { font-weight: 600; font-variant-numeric: tabular-nums; }
.cost-preview .flag-note { margin-top: 6px; color: var(--warn-ink); background: var(--warn-bg); padding: 6px 8px; border-radius: var(--r-sm); }

/* Fixed tables inside a form (ICS 209 blocks 30 to 32, ICS 221 block 6). */
.matrix-wrap { margin-top: 6px; }
table.matrix th[scope="row"] { font-weight: 500; text-align: left; min-width: 12em; }
table.matrix td { padding: 4px 6px; }
table.matrix td.kind-int input, table.matrix td.kind-number input { width: 6.5em; min-height: var(--ctl-sm); text-align: right; }
table.matrix td.kind-text input { min-width: 9em; min-height: var(--ctl-sm); }
table.matrix td.kind-bool { text-align: center; }
table.matrix td.kind-bool input { width: 22px; height: 22px; }

.geo-row { margin: 2px 0 8px; align-items: center; }
.geo-status { margin: 0; }

.closed-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin: 0 0 12px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--muted);
  border-radius: var(--r-sm);
  background: var(--soft);
}
.closed-banner p { margin: 0; max-width: 80ch; }
fieldset.readonly { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.readonly .btn, fieldset.readonly .geo-row { display: none; }
fieldset.readonly input, fieldset.readonly textarea, fieldset.readonly select { opacity: 1; color: var(--text); background: var(--soft); }

.signoffs { display: grid; gap: 4px; justify-items: start; margin: 6px 0 0; }
.signoffs .signoff { margin: 0; font-size: 0.88rem; color: var(--muted); }
.signoffs .signoff.is-current { color: var(--ok); font-weight: 500; }

.tag-level { font-weight: 600; }
.tag-level.lvl-destroyed { background: #4a0d0d; color: #fff; }
.tag-level.lvl-major { background: #b42318; color: #fff; }
.tag-level.lvl-minor { background: #f0b43c; color: #2b1d00; }
.tag-level.lvl-affected { background: #dfe7ec; color: #22313b; }
.tag-level.lvl-inaccessible { background: #5d6973; color: #fff; }

.practice-box { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }

img.is-loading { background: var(--soft); min-width: 40px; min-height: 30px; }
.photo-gone { font-size: 0.75rem; color: var(--muted); padding: 4px; }

.help h3 { margin: 14px 0 6px; }
.help ol, .help ul { margin: 0 0 10px; padding-left: 22px; }
.help li { margin: 0 0 4px; }

/* Printouts stay black on white in every theme. */
.preview, .p-doc { background: #fff; color: #000; }

[hidden] { display: none !important; }

/* ---------- printed forms (also used for on-screen previews) ---------- */

#printArea { display: none; }

.p-doc { color: #000; font: 9.5pt/1.3 Arial, Helvetica, sans-serif; }
.p-page { position: relative; }
.p-title { text-align: center; font-size: 13pt; font-weight: 700; margin: 0 0 6px; letter-spacing: 0.02em; }
.p-section { font-weight: 700; font-size: 9pt; letter-spacing: 0.08em; margin: 8px 0 2px; padding: 2px 6px; background: #000; color: #fff; }
table.p-head { width: 100%; border-collapse: collapse; margin: 0 0 -1px; table-layout: fixed; }
table.p-head td { border: 1px solid #000; padding: 3px 6px; vertical-align: top; }
.p-lbl { display: block; font-size: 7.5pt; font-weight: 700; text-transform: uppercase; }
.p-val { display: block; min-height: 1.2em; overflow-wrap: anywhere; }
.p-block { border: 1px solid #000; margin: -1px 0 0; break-inside: auto; }
.p-bh { font-weight: 700; font-size: 8.5pt; background: #e6e6e6; border-bottom: 1px solid #000; padding: 2px 6px; }
.p-bb { padding: 4px 6px; }
.p-sub { font-weight: 700; font-size: 8pt; margin: 4px 0 2px; }
.p-text { white-space: pre-wrap; overflow-wrap: anywhere; min-height: 2.6em; }
.p-text.p-tall { min-height: 7em; }
.p-line { min-height: 1.3em; overflow-wrap: anywhere; }
.p-note { font-style: italic; margin: 4px 0; }
.p-sketch { min-height: 3.5in; }
.p-img { display: block; max-width: 100%; max-height: 6in; margin: 2px auto; }
table.p-kv { width: 100%; border-collapse: collapse; table-layout: fixed; }
table.p-kv td { padding: 2px 4px; vertical-align: top; border-bottom: 1px solid #bbb; overflow-wrap: break-word; }
table.p-kv td.p-k { width: 22%; font-weight: 700; font-size: 8pt; }
.p-col table.p-kv td.p-k, .p-pair table.p-kv td.p-k { width: 42%; }
table.p-kv td.p-sig { height: 2.2em; }
table.p-grid { width: 100%; border-collapse: collapse; margin: 2px 0; }
table.p-grid th, table.p-grid td { border: 1px solid #000; padding: 2px 4px; vertical-align: top; text-align: left; overflow-wrap: break-word; word-break: normal; }
table.p-grid th { background: #f0f0f0; font-size: 7.5pt; }
table.p-grid td { white-space: pre-wrap; }
table.p-grid thead { display: table-header-group; }
table.p-grid tr { break-inside: avoid; }
table.p-grid tr.p-blank td { height: 1.6em; }
table.p-grid .p-num { text-align: right; white-space: nowrap; }
table.p-grid tr.p-sum td { font-weight: 700; background: #f5f5f5; }
table.p-grid tr.p-total td { background: #e6e6e6; }
table.p-grid tr.p-flag td:first-child { border-left: 4px solid #000; }
table.p-cost { font-size: 8pt; }
.p-checks { display: flex; flex-wrap: wrap; gap: 2px 16px; padding: 2px 0; }
.p-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 6px; }
.p-col { min-width: 0; }
/* Metrics: keep each number on one line. */
.p-metrics .p-v { white-space: nowrap; width: 17%; text-align: right; }
.p-pair { display: grid; grid-template-columns: 1fr 1fr; margin-top: -1px; }
.p-pair > .p-block { margin: 0; min-width: 0; }
.p-pair > .p-block + .p-block { margin-left: -1px; }
.p-org { padding: 8px 0 4px; }
.p-org-row { display: flex; justify-content: center; gap: 10px; position: relative; margin: 0 0 16px; }
.p-org-box { border: 1px solid #000; padding: 4px 6px; width: 1.62in; min-height: 0.55in; text-align: center; }
.p-org-box .p-val { white-space: pre-wrap; overflow-wrap: break-word; }
.p-org-top::after { content: ""; position: absolute; left: 50%; bottom: -17px; height: 16px; border-left: 1px solid #000; }
.p-org-staff { justify-content: flex-end; }
.p-org-sections { border-top: 1px solid #000; padding-top: 12px; }
.p-cert { margin: 2px 0 6px; }
.p-foot { margin-top: 6px; font-size: 8pt; }
.p-foot-main { font-weight: 700; }
.p-audit { color: #333; }
.p-warn { font-weight: 700; margin-top: 2px; }
.p-exercise { text-align: center; font-weight: 700; font-size: 11pt; letter-spacing: 0.2em; border: 2px solid #000; padding: 2px 0; margin: 0 0 6px; }
.p-photos { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0; }
.p-thumb { width: 1.45in; height: 1.1in; object-fit: cover; border: 1px solid #000; }
div.p-thumb, div.p-figimg { display: flex; align-items: center; justify-content: center; text-align: center; font-size: 7.5pt; padding: 4px; }
.p-appendix { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.p-fig { margin: 0; break-inside: avoid; border: 1px solid #000; padding: 4px; }
.p-figimg { display: block; width: 100%; height: 3.1in; object-fit: contain; }
.p-cap { font-size: 8pt; margin-top: 3px; overflow-wrap: anywhere; }
table.p-211 { font-size: 7pt; table-layout: fixed; }
table.p-211 th { font-size: 6.5pt; }
table.p-211 tr.p-blank td { height: 2.4em; }
table.p-211 th:nth-child(1) { width: 3.5%; }
table.p-211 th:nth-child(2) { width: 6%; }
table.p-211 th:nth-child(3) { width: 5%; }
table.p-211 th:nth-child(4) { width: 5%; }
table.p-211 th:nth-child(5) { width: 3.5%; }
table.p-211 th:nth-child(6) { width: 7.5%; }
table.p-211 th:nth-child(7) { width: 3%; }
table.p-211 th:nth-child(8) { width: 5%; }
table.p-211 th:nth-child(9) { width: 6.5%; }
table.p-211 th:nth-child(10) { width: 6%; }
table.p-211 th:nth-child(11) { width: 5%; }
table.p-211 th:nth-child(12) { width: 7%; }
table.p-211 th:nth-child(13) { width: 6%; }
table.p-211 th:nth-child(14) { width: 6.5%; }
table.p-211 th:nth-child(15) { width: 5%; }
table.p-211 th:nth-child(16) { width: 6.5%; }
table.p-211 th:nth-child(17) { width: 7%; }
table.p-211 th:nth-child(18) { width: 5.5%; }
.p-cover-title { font-size: 22pt; margin-top: 0.6in; }
.p-cover-sub { text-align: center; font-size: 12pt; margin: 0 0 18px; }
.p-step { margin: 0 0 6px; }
.p-flagnote { font-size: 8pt; margin-top: 4px; }
table.p-matrix { width: auto; min-width: 60%; }
table.p-matrix td.p-c-int, table.p-matrix td.p-c-number { text-align: right; min-width: 0.9in; }
table.p-matrix td.p-c-bool { text-align: center; width: 0.7in; }
td.p-rowhead { font-weight: 700; font-size: 8pt; }
table.p-215 { font-size: 7.5pt; table-layout: auto; }
table.p-215 tr.p-215-first td { border-top: 2px solid #000; }
table.p-215 td.p-rowhead { width: 0.45in; }
.p-org-207 .p-org-box { width: 1.75in; }
.p-org-207 .p-org-sections { align-items: flex-start; gap: 8px; }
.p-org-col { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.p-org-sub { min-height: 0.4in; font-size: 8pt; }
.p-org-unit { width: 1.55in !important; margin-left: 0.2in; }
.p-signoff { font-weight: 700; color: #000; }
.preview .p-break { margin-top: 18px; padding-top: 18px; border-top: 2px dashed #999; }

@media print {
  @page { size: letter; margin: 11mm; }
  @page wide { size: letter landscape; margin: 9mm; }
  html, body { background: #fff !important; }
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block !important; }
  .p-doc + .p-doc { break-before: page; }
  .p-break { break-before: page; }
  .p-wide { page: wide; }
  .p-block { break-inside: auto; }
  .p-bh { break-after: avoid; }
}
