/* SIM Incident Reporting. Palette from the plant floor: dark machine green, concrete, hi-vis yellow. */
@font-face { font-family: Barlow; font-weight: 400; font-display: swap; src: url(/fonts/barlow-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: Barlow; font-weight: 500; font-display: swap; src: url(/fonts/barlow-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: Barlow; font-weight: 600; font-display: swap; src: url(/fonts/barlow-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 600; font-display: swap; src: url(/fonts/barlow-semi-condensed-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 700; font-display: swap; src: url(/fonts/barlow-semi-condensed-latin-700-normal.woff2) format("woff2"); }

:root {
  --ink: #12211d; --slate: #30463f; --muted: #586762; --paper: #eceeea; --surface: #fff; --line: #d0d7cf;
  --hivis: #f6c500; --hivis-deep: #d9ab00; --alert: #b3290f; --alert-bg: #fbe9e4; --ok: #1f6e45; --ok-bg: #e3f1e8;
  --amber: #8a5600; --amber-bg: #fdf1cf; --focus: #0b5cad;
  --body: Barlow, "Segoe UI", system-ui, sans-serif; --head: "Barlow Semi Condensed", Barlow, "Segoe UI", system-ui, sans-serif;
  --tab-h: 62px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 16px/1.5 var(--body); color: var(--ink); background: var(--paper); }
h1, h2, h3 { font-family: var(--head); line-height: 1.15; margin: 0; }
h1 { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.005em; }
h2 { font-size: 1.25rem; font-weight: 600; margin: 1.6rem 0 .6rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
h3 { font-size: 1rem; font-weight: 600; margin: 1.1rem 0 .3rem; color: var(--slate); }
p { margin: 0 0 .7rem; }
a { color: #0b4f8a; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--hivis); color: var(--ink); padding: .5rem 1rem; z-index: 50; }
.skip:focus { left: 0; }
.boot { padding: 3rem 1.5rem; color: var(--muted); }
.hint { color: var(--muted); font-size: .92rem; margin: .3rem 0 0; }
.hint.boxed { border: 1px dashed var(--line); padding: 1rem; background: #f6f8f4; }
.lede { color: var(--slate); max-width: 68ch; }

/* ---- frame */
#app { min-height: 100dvh; display: grid; grid-template: "top top" auto "stripe stripe" auto "side main" 1fr / 236px minmax(0, 1fr); }
.topbar { grid-area: top; background: var(--ink); color: #fff; display: flex; align-items: center; gap: .75rem; padding: .55rem 1.1rem; padding-top: calc(.55rem + env(safe-area-inset-top)); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: .6rem; color: inherit; text-decoration: none; margin-right: auto; }
.brand-mark { background: var(--hivis); color: var(--ink); font: 700 1.05rem/1 var(--head); padding: .38rem .45rem .34rem; letter-spacing: .02em; }
.brand-name { font: 600 1.1rem/1 var(--head); }
.brand.big { color: var(--ink); margin: 0 0 1rem; }
.brand.big .brand-mark { font-size: 1.5rem; padding: .5rem .6rem .45rem; }
.brand.big .brand-name { font-size: 1.5rem; }
/* The one loud element: hazard tape under the header */
.stripe { grid-area: stripe; height: 6px; background: repeating-linear-gradient(-45deg, var(--hivis) 0 12px, var(--ink) 12px 24px); }
.sync-chip { font: 500 .85rem/1 var(--body); border: 1px solid #ffffff40; background: transparent; color: #fff; padding: .45rem .7rem; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; gap: .45rem; }
.sync-chip::before { content: ""; width: .55rem; height: .55rem; border-radius: 50%; background: #58c98a; }
.sync-chip.warn::before { background: var(--hivis); }
.sync-chip.bad::before { background: #ff7a5c; }
.sync-chip.busy::before { background: #9fd3ff; animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .3; } }
.who { width: 2.25rem; height: 2.25rem; border-radius: 50%; border: 0; background: var(--slate); color: #fff; font: 600 .85rem var(--body); cursor: pointer; }
.sidenav { grid-area: side; background: #fff; border-right: 1px solid var(--line); padding: 1rem .75rem; display: flex; flex-direction: column; gap: .15rem; position: sticky; top: 58px; align-self: start; height: calc(100dvh - 58px); overflow: auto; }
.sidenav a { color: var(--ink); text-decoration: none; padding: .6rem .75rem; border-radius: 6px; font-weight: 500; border-left: 4px solid transparent; }
.sidenav a:hover { background: var(--paper); }
.sidenav a[aria-current="page"] { background: var(--paper); border-left-color: var(--hivis-deep); font-weight: 600; }
.sidenav a.cta { background: var(--hivis); margin: .2rem 0 .5rem; font-weight: 600; text-align: center; border-left: 0; }
.sidenav a.cta:hover { background: var(--hivis-deep); }
.tabbar { display: none; }
main { grid-area: main; padding: 1.6rem 2rem 4rem; max-width: 1180px; width: 100%; outline: none; }

@media (max-width: 860px) {
  #app { grid-template: "top" auto "stripe" auto "main" 1fr / minmax(0, 1fr); }
  .sidenav { display: none; }
  main { padding: 1.1rem 1rem calc(var(--tab-h) + 2.2rem + env(safe-area-inset-bottom)); }
  h1 { font-size: 1.55rem; }
  .brand-name { display: none; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset: auto 0 0 0; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 20; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
  .tabbar a { display: grid; place-items: center; text-decoration: none; color: var(--muted); font: 500 .82rem var(--body); border-top: 3px solid transparent; }
  .tabbar a[aria-current="page"] { color: var(--ink); border-top-color: var(--hivis-deep); font-weight: 600; }
  .tabbar a.cta { background: var(--hivis); color: var(--ink); font-weight: 600; margin: 7px 4px; border-radius: 8px; border: 0; }
}

/* ---- buttons, chips */
.btn { font: 600 .95rem/1.1 var(--body); padding: .62rem .95rem; border: 1.5px solid var(--slate); background: #fff; color: var(--ink); border-radius: 6px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; min-height: 2.6rem; }
.btn:hover { background: var(--paper); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: var(--slate); }
.btn.danger { color: var(--alert); border-color: var(--alert); }
.btn.danger:hover { background: var(--alert-bg); }
.btn.big { font-size: 1.05rem; padding: .85rem 1.3rem; }
.btn.small { min-height: 2rem; padding: .35rem .65rem; font-size: .88rem; }
.btn.link { border: 0; background: none; color: #0b4f8a; text-decoration: underline; font-weight: 500; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.chip { display: inline-block; font: 600 .78rem/1 var(--body); padding: .28rem .5rem; border-radius: 4px; background: #e4e9e2; color: var(--slate); white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.bad { background: var(--alert-bg); color: var(--alert); }
.chip.warn { background: var(--amber-bg); color: var(--amber); }
.chip.open { background: #e2ecf6; color: #0b4f8a; }
.chips { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .5rem; }

/* ---- home */
.home-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.3rem; }
.home-head .lede { margin: .3rem 0 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.tile { background: #fff; padding: 1rem 1rem .9rem; text-decoration: none; color: var(--ink); display: grid; gap: .15rem; }
.tile:hover { background: #f8faf6; }
.tile strong { font: 700 2.1rem/1 var(--head); font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: .92rem; }
.tile.bad strong { color: var(--alert); }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 2rem; }
.more { display: inline-block; margin-top: .6rem; }

/* ---- lists */
.list-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; }
.list-head h2 { margin: 0; }
.tabs { display: flex; gap: .25rem; border-bottom: 2px solid var(--line); margin: .8rem 0; overflow-x: auto; }
.tabs button { font: 500 .98rem var(--body); background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -2px; padding: .6rem .8rem; cursor: pointer; color: var(--muted); white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.tabs .n { margin-left: .4rem; font-size: .82rem; background: #e4e9e2; padding: .1rem .4rem; border-radius: 999px; font-variant-numeric: tabular-nums; }
.filters { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin: .6rem 0 .9rem; }
.filters input[type="search"], .filters input[type="text"] { flex: 1 1 220px; max-width: 420px; }
.filters select { width: auto; }
.count { margin: 0 0 0 auto; color: var(--muted); font-size: .9rem; }
.rows { display: grid; gap: .5rem; }
.rowcard { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1.5fr); gap: .4rem 1.5rem; align-items: center; background: #fff; border: 1px solid var(--line); border-left: 6px solid #9aa8a2; padding: .75rem 1rem; text-decoration: none; color: var(--ink); text-align: left; font: inherit; width: 100%; cursor: pointer; }
.rowcard.static { cursor: default; }
a.rowcard:hover, button.rowcard:hover { border-color: var(--slate); border-left-color: inherit; }
.rowcard.s-open { border-left-color: #2a73b8; }
.rowcard.s-ok { border-left-color: var(--ok); }
.rowcard.s-bad { border-left-color: var(--alert); }
.rc-title { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.rc-title strong { font: 600 1.02rem var(--head); letter-spacing: .01em; }
.rc-main p { margin: .25rem 0 0; color: var(--slate); font-size: .93rem; overflow-wrap: anywhere; }
.rc-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .3rem 1rem; margin: 0; }
.rc-meta dt { font-size: .76rem; color: var(--muted); }
.rc-meta dd { margin: 0; font-size: .92rem; font-weight: 500; overflow-wrap: anywhere; }
.empty-list { color: var(--muted); padding: 2rem 1rem; text-align: center; border: 1px dashed var(--line); background: #f6f8f4; margin: 0; }
.btn.more { justify-self: center; margin-top: .4rem; }
@media (max-width: 860px) {
  .rowcard { grid-template-columns: 1fr; }
  .rc-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .count { margin-left: 0; width: 100%; }
}

/* ---- detail */
.back { display: inline-block; margin-bottom: .7rem; text-decoration: none; font-weight: 500; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.detail-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.steps { list-style: none; counter-reset: s; display: grid; grid-template-columns: repeat(5, 1fr); padding: 0; margin: 1.3rem 0 1rem; }
.steps li { counter-increment: s; font-size: .86rem; color: var(--muted); border-top: 4px solid var(--line); padding-top: .45rem; padding-right: .5rem; }
.steps li::before { content: counter(s) ". "; font-variant-numeric: tabular-nums; }
.steps li.done { border-top-color: var(--ok); color: var(--ink); }
.steps li.now { border-top-color: var(--hivis-deep); color: var(--ink); font-weight: 600; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 0 2.5rem; }
.detail-grid > section > h2:first-child { margin-top: 1rem; }
@media (max-width: 860px) { .detail-grid { grid-template-columns: 1fr; } .steps li { font-size: .74rem; } }
.prose { white-space: pre-wrap; max-width: 72ch; overflow-wrap: anywhere; }
.details { margin: .8rem 0 0; border-top: 1px solid var(--line); }
.details > div { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: .8rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.details dt { color: var(--muted); font-size: .92rem; }
.details dd { margin: 0; overflow-wrap: anywhere; }
.photo-full, .photo-preview { max-width: 100%; max-height: 420px; border: 1px solid var(--line); display: block; background: #fff; }
.plain { list-style: none; padding: 0; margin: 0 0 .6rem; display: flex; gap: .35rem; flex-wrap: wrap; }
.banner { padding: .8rem 1rem; border-left: 6px solid; margin: 1rem 0; }
.banner p { margin: .3rem 0 0; white-space: pre-wrap; }
.banner .btn { margin-top: .6rem; }
.banner.bad { background: var(--alert-bg); border-color: var(--alert); }
.banner.ok { background: var(--ok-bg); border-color: var(--ok); }
.panel { background: #fff; border: 1px solid var(--line); padding: 1rem 1.1rem 1.2rem; margin-top: 1.6rem; }
.panel > h2:first-child { margin-top: 0; }
.empty { padding: 3rem 0; max-width: 60ch; }
.empty p { margin: .6rem 0 1rem; }

/* ---- forms */
.form { max-width: 860px; }
.form .lede { margin-top: .5rem; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.25rem; margin-top: 1.2rem; }
.fields.nested { grid-column: 1 / -1; margin: 0; padding: 1rem; background: #f6f8f4; border: 1px solid var(--line); grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field.wide { grid-column: 1 / -1; }
@media (max-width: 640px) { .fields, .fields.nested { grid-template-columns: 1fr; } }
.field > label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .96rem; }
.req { color: var(--alert); }
input[type="text"], input[type="email"], input[type="search"], input[type="date"], input[type="time"], input[type="number"], select, textarea {
  width: 100%; font: 400 1rem/1.4 var(--body); color: var(--ink); background: #fff; border: 1.5px solid #8b9993; border-radius: 6px; padding: .6rem .7rem; min-height: 2.75rem; }
textarea { resize: vertical; }
input[readonly] { background: #f0f3ee; border-color: var(--line); color: var(--slate); }
.derived { display: block; padding: .6rem .7rem; background: #f0f3ee; border: 1.5px solid var(--line); border-radius: 6px; min-height: 2.75rem; font-weight: 500; }
.segmented { display: inline-flex; flex-wrap: wrap; border: 1.5px solid #8b9993; border-radius: 6px; overflow: hidden; background: #fff; }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; inset: 0; pointer-events: none; }
.segmented span { display: block; padding: .6rem 1.15rem; min-width: 4.2rem; text-align: center; font-weight: 500; border-right: 1px solid var(--line); }
.segmented label:last-child span { border-right: 0; }
.segmented input:checked + span { background: var(--ink); color: #fff; }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -3px; }
.tags { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.tag { background: #e4e9e2; border-radius: 4px; padding: .3rem .3rem .3rem .6rem; font-size: .9rem; display: inline-flex; align-items: center; gap: .3rem; }
.tag button { border: 0; background: none; font-size: 1.1rem; line-height: 1; cursor: pointer; color: var(--slate); padding: .1rem .35rem; border-radius: 4px; }
.tag button:hover { background: #cfd6cd; }
.checklist { max-height: 46vh; overflow: auto; border: 1px solid var(--line); margin-top: .6rem; }
.check { display: flex; gap: .6rem; align-items: flex-start; padding: .55rem .7rem; border-bottom: 1px solid #e6eae4; cursor: pointer; }
.check input { width: 1.15rem; height: 1.15rem; margin-top: .15rem; accent-color: var(--ink); flex: none; }
.row-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: .6rem 0 0; }
.file, .inline { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.inline input { flex: 1 1 160px; }
.file-name { color: var(--slate); font-size: .93rem; overflow-wrap: anywhere; }
.photo-preview { margin-top: .7rem; max-height: 260px; }
.picker { position: relative; }
.menu { position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 2px); background: #fff; border: 1.5px solid var(--slate); border-radius: 6px; max-height: 280px; overflow: auto; box-shadow: 0 6px 18px #12211d2e; }
.menu button { display: grid; width: 100%; text-align: left; border: 0; background: none; padding: .5rem .7rem; font: inherit; cursor: pointer; border-bottom: 1px solid #e6eae4; }
.menu button:hover, .menu button:focus-visible { background: var(--paper); }
.menu button span { color: var(--muted); font-size: .86rem; }
.menu .hint { padding: .6rem .7rem; margin: 0; }
.form-error { background: var(--alert-bg); color: var(--alert); border-left: 6px solid var(--alert); padding: .7rem .9rem; margin: 1rem 0 0; font-weight: 500; }
.form-actions { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1.4rem; padding-top: 1rem; border-top: 1px solid var(--line); }

/* ---- dialogs, toasts */
dialog { border: 0; border-radius: 8px; padding: 1.3rem 1.4rem; width: min(520px, calc(100vw - 2rem)); box-shadow: 0 18px 50px #12211d59; color: var(--ink); }
dialog.wide { width: min(720px, calc(100vw - 2rem)); }
dialog::backdrop { background: #12211d99; }
dialog h2 { margin: 0 0 .8rem; }
.dialog-actions { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1.2rem; }
.scan-video { width: 100%; max-height: 60vh; background: #000; border-radius: 6px; }
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + 1.2rem); display: grid; gap: .5rem; z-index: 60; width: min(560px, calc(100vw - 2rem)); pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: .8rem 1rem; border-radius: 6px; border-left: 6px solid #58c98a; box-shadow: 0 8px 24px #12211d40; }
.toast.error { border-left-color: #ff7a5c; }

/* ---- sign-in */
.login { grid-column: 1 / -1; grid-row: 1 / -1; display: grid; place-items: center; padding: 1.5rem; min-height: 100dvh; background: var(--paper); }
.login-card { background: #fff; border: 1px solid var(--line); padding: 2rem; width: min(440px, 100%); }
.login-card .stripe { margin: 0 -2rem 1.5rem; }
.login-card h1 { margin-bottom: .4rem; }
.login-step { display: grid; gap: 1rem; margin-top: 1.2rem; }
.otp { font: 600 1.5rem var(--head); letter-spacing: .35em; text-align: center; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; scroll-behavior: auto !important; } }
@media print { .topbar, .stripe, .sidenav, .tabbar, .detail-actions, .back { display: none !important; } #app { display: block; } }
