/* Nako HSE: light, high-contrast work tool for use outdoors on a phone. Colour only carries meaning (status, non-compliance). */
:root {
  --paper: oklch(0.975 0.005 85);
  --surface: oklch(0.995 0.002 85);
  --sunk: oklch(0.945 0.007 85);
  --line: oklch(0.87 0.008 85);
  --line-strong: oklch(0.74 0.01 85);
  --ink: oklch(0.22 0.012 85);
  --ink-2: oklch(0.40 0.012 85);
  --ink-3: oklch(0.50 0.01 85);
  --accent: oklch(0.45 0.13 252);
  --open: oklch(0.48 0.16 30);
  --open-bg: oklch(0.95 0.03 35);
  --closed: oklch(0.43 0.10 155);
  --closed-bg: oklch(0.95 0.03 155);
  --radius: 6px;
  --tap: 44px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.625rem; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.1875rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
table, .num, time { font-variant-numeric: tabular-nums; }

/* ---- app bar ---- */
.bar { background: var(--ink); color: var(--paper); }
.bar-in { max-width: 1120px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 4px 20px; flex-wrap: wrap; min-height: 56px; }
.brand { color: var(--paper); text-decoration: none; font-weight: 700; font-size: 1.0625rem; letter-spacing: 0.01em; display: flex; align-items: baseline; gap: 8px; }
.brand span { font-weight: 450; color: oklch(0.80 0.01 85); font-size: 0.875rem; }
.bar nav { display: flex; gap: 2px; }
.bar nav a { color: oklch(0.86 0.008 85); text-decoration: none; padding: 8px 10px; border-radius: var(--radius); font-size: 0.9375rem; }
.bar nav a:hover { background: oklch(0.30 0.012 85); color: var(--paper); }
.bar nav a[aria-current] { color: var(--paper); background: oklch(0.32 0.012 85); }
.bar .co { margin-left: auto; color: oklch(0.78 0.01 85); font-size: 0.8125rem; }
.bar form { margin: 0; }
.bar .link { color: oklch(0.86 0.008 85); }

/* ---- page ---- */
.wrap { max-width: 1120px; margin: 0 auto; padding: 24px 16px 96px; }
.crumb { font-size: 0.875rem; margin-bottom: 6px; }
.crumb a { color: var(--ink-2); }
.pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.pagehead .sub { color: var(--ink-2); margin-top: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
section { margin-top: 36px; }
section > h2 { margin-bottom: 12px; display: flex; align-items: baseline; gap: 10px; }
section > h2 .count { font-size: 0.875rem; font-weight: 500; color: var(--ink-3); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.muted { color: var(--ink-2); }
.prose { max-width: 70ch; }
.prose h2 { margin: 28px 0 8px; }
.prose ol, .prose ul { padding-left: 1.3em; margin: 0; }
.prose li + li { margin-top: 4px; }
.prose p { margin-top: 10px; }

/* ---- buttons ---- */
.btn, button { font: inherit; font-size: 0.9375rem; font-weight: 550; min-height: var(--tap); padding: 0 16px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; white-space: nowrap;
  transition: background-color 150ms ease-out, border-color 150ms ease-out; }
.btn:hover, button:hover { background: var(--sunk); }
.btn.primary, button.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.primary:hover, button.primary:hover { background: oklch(0.32 0.012 85); }
.btn.danger, button.danger { color: var(--open); border-color: var(--line); }
.btn.danger:hover, button.danger:hover { background: var(--open-bg); border-color: var(--open); }
button.link { background: none; border: none; min-height: auto; padding: 8px 10px; font-weight: 450; }
button.link:hover { text-decoration: underline; background: none; }
.btn.sm, button.sm { min-height: 36px; padding: 0 12px; font-size: 0.875rem; }
form.inline { display: inline; margin: 0; }
.group { display: inline-flex; }
.group .btn { border-radius: 0; margin-left: -1px; }
.group .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.group .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }

/* ---- status ---- */
.badge { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 0.8125rem; font-weight: 600;
  background: var(--sunk); color: var(--ink-2); white-space: nowrap; }
.badge.open { background: var(--open-bg); color: var(--open); }
.badge.closed { background: var(--closed-bg); color: var(--closed); }
.warn { color: var(--open); font-weight: 600; }

/* ---- tables (visit list) ---- */
table.list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list th { text-align: left; font-size: 0.8125rem; font-weight: 600; color: var(--ink-3); background: var(--sunk); padding: 10px 14px; border-bottom: 1px solid var(--line); }
.list td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.list tr:last-child td { border-bottom: none; }
.list tbody tr:hover { background: oklch(0.985 0.004 85); }
.list .r { text-align: right; }
.list a.row-link { font-weight: 600; color: var(--ink); text-decoration: none; }
.list a.row-link:hover { color: var(--accent); text-decoration: underline; }

/* ---- detail lists ---- */
dl.details { display: grid; grid-template-columns: minmax(150px, 220px) 1fr; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.details dt, .details dd { padding: 10px 14px; border-bottom: 1px solid var(--line); margin: 0; }
.details dt { color: var(--ink-3); font-size: 0.875rem; font-weight: 550; background: var(--sunk); }
.details dt:last-of-type, .details dd:last-of-type { border-bottom: none; }

/* ---- findings ---- */
ol.findings { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.findings > li { padding: 16px 18px; display: grid; grid-template-columns: 2rem 1fr; gap: 4px 12px; }
.findings > li + li { border-top: 1px solid var(--line); }
.findings .no { font-weight: 700; color: var(--ink-3); font-size: 1.0625rem; padding-top: 1px; }
.fhead { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.fhead strong { font-weight: 600; }
.fdesc { margin-top: 6px; max-width: 75ch; }
.fmeta { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 8px 0 0; font-size: 0.875rem; color: var(--ink-2); }
.fmeta div { display: flex; gap: 6px; }
.fmeta dt { color: var(--ink-3); }
.fmeta dd { margin: 0; color: var(--ink); }
.fbody { grid-column: 2; }
.fbody .actions { margin-top: 12px; }

/* ---- checklist view ---- */
.checks { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.check { padding: 14px 18px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; }
.check + .check { border-top: 1px solid var(--line); }
.check h3 { grid-column: 1 / -1; }
.check ul { list-style: none; margin: 0; padding: 0; font-size: 0.9375rem; max-width: 720px; }
.check li { display: flex; justify-content: space-between; gap: 16px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.check li:last-child { border-bottom: none; }
.check li span:first-child { color: var(--ink-2); }

/* ---- photos ---- */
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.thumbs img { width: 88px; height: 88px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); display: block; background: var(--sunk); }
.thumbs a.file { font-size: 0.875rem; align-self: center; }

/* ---- forms ---- */
.form { display: grid; gap: 20px; }
.form fieldset.group-box { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 20px; margin: 0; display: grid; gap: 18px; }
.group-box > legend { font-size: 1.1875rem; font-weight: 650; padding: 0; float: left; width: 100%; }
.group-box > legend + * { clear: both; }
.cols { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.field { display: grid; gap: 6px; min-width: 0; border: 0; padding: 0; margin: 0; }
.field > label, .field > legend { font-weight: 600; font-size: 0.9375rem; padding: 0; }
.req { color: var(--open); font-weight: 600; }
input[type=text], input[type=date], input[type=time], input[type=password], input:not([type]), select, textarea {
  font: inherit; color: var(--ink); width: 100%; min-height: var(--tap); padding: 9px 12px; border: 1px solid var(--line-strong);
  border-radius: var(--radius); background: var(--surface); }
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid color-mix(in oklch, var(--accent) 35%, transparent); border-color: var(--accent); }
input[type=file] { font: inherit; font-size: 0.9375rem; max-width: 100%; }
input[type=file]::file-selector-button { font: inherit; font-weight: 550; min-height: var(--tap); padding: 0 14px; margin-right: 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--sunk); color: var(--ink); cursor: pointer; }
.hint { font-size: 0.8125rem; color: var(--ink-3); }

/* tappable options: real radios and checkboxes, the whole row is the target */
.opts { display: grid; gap: 6px; }
.opt { display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; font-weight: 450; }
.opt:hover { border-color: var(--line-strong); }
.opt input { width: 20px; height: 20px; margin: 0; accent-color: var(--ink); flex: none; }
.opt:has(input:checked) { border-color: var(--ink); background: var(--sunk); font-weight: 550; }
.opts.row { grid-template-columns: repeat(auto-fit, minmax(56px, 1fr)); }
.opts.row .opt { justify-content: center; }

/* grid question: one row per item, answers as a segmented row */
.gitem { display: grid; gap: 6px; padding-top: 12px; border-top: 1px dashed var(--line); }
.gitem:first-of-type { border-top: none; padding-top: 0; }
.gitem > span { font-size: 0.9375rem; color: var(--ink-2); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; max-width: 640px; }
.seg .opt { justify-content: center; text-align: center; font-size: 0.875rem; padding: 6px 6px; min-width: 0; overflow-wrap: anywhere; hyphens: auto; }
.seg .opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg .opt:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.seg .opt:has(input:checked) { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.opt.bad:has(input:checked) { border-color: var(--open); background: var(--open-bg); color: var(--open); }
.seg .opt.bad:has(input:checked) { background: var(--open); border-color: var(--open); color: var(--surface); }

.saved { display: flex; flex-wrap: wrap; gap: 10px; }
.saved label { display: grid; gap: 4px; font-size: 0.8125rem; color: var(--ink-2); }
.saved img { width: 88px; height: 88px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); display: block; }
.saved input { width: 18px; height: 18px; vertical-align: middle; accent-color: var(--open); }

.formbar { position: sticky; bottom: 0; z-index: 2; background: var(--paper); box-shadow: 0 -8px 16px -12px oklch(0.22 0.012 85 / 0.25); border-top: 1px solid var(--line);
  padding: 12px 0; display: flex; gap: 12px; align-items: center; margin-top: 4px; }
.errors { border: 1px solid var(--open); background: var(--open-bg); border-radius: var(--radius); padding: 16px 20px; max-width: 70ch; }
.errors ul { margin: 8px 0 0; padding-left: 1.2em; }

.gsec { display: grid; gap: 12px; }
.gsec + .gsec { border-top: 1px solid var(--line); padding-top: 18px; }
.form-body { display: grid; gap: 18px; }
.sechead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.sechead h2 { margin: 0; }

/* ---- login ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login .panel { width: 100%; max-width: 380px; display: grid; gap: 18px; padding: 28px; }
.login .brand-dark { font-weight: 700; font-size: 1.125rem; }
.login .brand-dark span { font-weight: 450; color: var(--ink-3); margin-left: 6px; font-size: 0.9375rem; }
.login .msg { color: var(--open); font-weight: 550; }

.empty { background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 28px 24px; max-width: 70ch; }
.empty p + p { margin-top: 8px; }

/* ---- phone ---- */
@media (max-width: 720px) {
  .wrap { padding-top: 18px; }
  h1 { font-size: 1.375rem; }
  .bar .co, .brand span { display: none; }
  .bar-in { gap: 4px 8px; flex-wrap: nowrap; }
  .bar nav a { padding: 8px 8px; }
  .bar form { margin-left: auto; }
  .bar .link { padding: 8px 4px; }
  .fmeta div { flex-direction: column; gap: 0; }
  .pagehead { align-items: stretch; flex-direction: column; margin-bottom: 20px; }
  .pagehead .actions .btn, .pagehead .actions form, .pagehead .actions .group { flex: 1 1 auto; }
  .pagehead .actions form button { width: 100%; }
  .group .btn { flex: 1; }
  table.list thead { display: none; }
  table.list, .list tbody, .list tr, .list td { display: block; }
  .list tr { padding: 12px 14px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; }
  .list tr:last-child { border-bottom: none; }
  .list td { padding: 0; border: none; }
  .list td.date { grid-column: 1; }
  .list td.loc { grid-column: 1; font-weight: 600; }
  .list td.meta { grid-column: 1; color: var(--ink-2); font-size: 0.875rem; }
  .list td.stat { grid-column: 2; grid-row: 1 / span 3; text-align: right; align-self: center; }
  .list .hide-sm { display: none; }
  dl.details { grid-template-columns: 1fr; }
  .details dt { border-bottom: none; padding-bottom: 2px; background: none; }
  .details dd { padding-top: 0; }
  .findings > li { padding: 14px; grid-template-columns: 1.6rem 1fr; }
  .check { grid-template-columns: 1fr; padding: 14px; }
  .form fieldset.group-box { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
