/* CAIRN from SafetyUnit
   Layout: a fixed left sidebar with the mark and the navigation, a fixed top bar
   with the page name, the client and the signed-in person, and only the content
   scrolling. On a phone the sidebar folds into a menu button.
   Palette from the CAIRN brand pack. Headings Outfit, body Public Sans. */

:root {
  --midnight: #1E1737; --charcoal: #393943; --magenta: #F12291; --violet: #9237C8; --indigo: #30428D; --blue: #4145B9;
  --amber: #FDBF00; --deep: #141128; --canvas: #FFFFFF; --panel: #F6F5FA; --panel-2: #EEEDF4; --line: #E3E1EC; --line-2: #CFCBDD;
  --ink: #1E1737; --ink-2: #4A475C; --ink-3: #7B7890; --ok: #1E7A3E; --warn: #B7791F; --bad: #B42318; --focus: #4145B9;
  --font-head: 'Outfit', Arial, sans-serif; --font-body: 'Public Sans', Arial, sans-serif;
  --radius: 12px; --radius-s: 8px; --side: 248px; --top: 60px;
}
* { box-sizing: border-box; }
html { background: var(--panel); }
body { margin: 0; background: var(--panel); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.5; }
h1, h2, h3 { font-family: var(--font-head); font-weight: 700; line-height: 1.2; margin: 0; text-wrap: balance; }
h1 { font-size: 26px; } h2 { font-size: 18px; } h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); font-weight: 600; margin: 18px 0 8px; }
p { margin: 0; } a { color: var(--blue); } .muted { color: var(--ink-3); } .small { font-size: 13px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Shell */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--canvas); border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 30; }
.side .mark { padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.side .mark img { height: 44px; width: auto; display: block; }
.side nav { padding: 12px 10px; overflow-y: auto; flex: 1; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-s); color: var(--ink-2); text-decoration: none; font-weight: 500; }
.side nav a.on { background: var(--panel); color: var(--midnight); font-weight: 600; }
.side nav a:hover { background: var(--panel); }
.side .help { padding: 14px 20px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.side .help a { color: var(--midnight); font-weight: 600; text-decoration: none; }
.top { position: fixed; top: 0; left: var(--side); right: 0; height: var(--top); background: var(--canvas); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; z-index: 20; gap: 16px; }
.top .page { font-family: var(--font-head); font-weight: 600; font-size: 17px; }
.top .who { display: flex; align-items: center; gap: 14px; font-size: 14px; color: var(--ink-2); }
.top .who b { color: var(--ink); }
.top .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--midnight); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; }
.main { grid-column: 2; padding: calc(var(--top) + 24px) 24px 48px; max-width: 1240px; }
.btn.menu-btn { display: none; }
body.busy .main { opacity: .55; transition: opacity .15s .15s; } body.busy { cursor: progress; }
.backdrop { display: none; }
.main:focus { outline: none; }
@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; }
  .side { transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vw rgba(20,17,40,.35); }
  .side.open ~ .backdrop { display: block; position: fixed; inset: 0; z-index: 25; }
  .top { left: 0; padding: 0 16px; }
  .top .who { gap: 8px; min-width: 0; } .top .who span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34vw; } .top .btn.small { white-space: nowrap; }
  .top .page { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .main { grid-column: 1; padding: calc(var(--top) + 16px) 16px 40px; }
  .btn.menu-btn { display: inline-flex; }
}

/* Pieces */
.card { background: var(--canvas); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card h2 { margin-bottom: 6px; }
.card .intro { color: var(--ink-2); margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; } .grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 720px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.stat { background: var(--canvas); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat .n { font-family: var(--font-head); font-size: 30px; font-weight: 800; }
.stat .l { color: var(--ink-2); font-size: 13px; }
.stat.warn .n { color: var(--warn); } .stat.bad .n { color: var(--bad); } .stat.ok .n { color: var(--ok); }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: var(--radius-s); border: 1px solid var(--line-2); background: var(--canvas); cursor: pointer; font-weight: 500; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--midnight); color: #fff; border-color: var(--midnight); }
.btn.amber { background: var(--amber); color: var(--midnight); border-color: var(--amber); font-weight: 600; }
.btn.quiet { border-color: transparent; background: transparent; color: var(--blue); padding-inline: 6px; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: 14px; }
.field input, .field select, .field textarea { padding: 9px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-s); background: var(--canvas); width: 100%; }
.field textarea { min-height: 90px; resize: vertical; }
.field .hint { color: var(--ink-3); font-size: 13px; }
.field .err { color: var(--bad); font-size: 13px; }
.req { color: var(--bad); font-weight: 400; font-size: 12px; margin-left: 6px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; flex-wrap: wrap; } .check .hint { flex-basis: 100%; margin-left: 26px; font-weight: 400; color: var(--ink-3); font-size: 13px; }
.check input { width: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl-wrap { overflow-x: auto; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-2); color: var(--ink-2); }
.pill.ok { background: #E3F3E8; color: var(--ok); } .pill.warn { background: #FBF0D9; color: var(--warn); } .pill.bad { background: #FBE4E1; color: var(--bad); } .pill.mid { background: var(--midnight); color: #fff; }
.notice { padding: 12px 16px; border-radius: var(--radius-s); background: var(--panel-2); margin-bottom: 16px; border: 1px solid var(--line); }
.notice.ok { background: #E3F3E8; border-color: #BFE3CB; } .notice.warn { background: #FBF0D9; border-color: #F0D9A8; } .notice.bad { background: #FBE4E1; border-color: #F2C3BD; }
.list { display: grid; gap: 8px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; background: var(--canvas); border: 1px solid var(--line); border-radius: var(--radius-s); text-decoration: none; color: inherit; }
.row:hover { border-color: var(--line-2); }
.row .t { font-weight: 600; } .row .s { color: var(--ink-3); font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-s); overflow: hidden; }
.seg button { padding: 8px 14px; border: 0; background: var(--canvas); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.on { background: var(--midnight); color: #fff; }
.seg button.on.yes { background: var(--ok); }
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.topic { background: var(--canvas); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: inherit; }
.topic .t { font-weight: 600; } .topic .s { color: var(--ink-3); font-size: 13px; }
.doc-body h2 { margin: 18px 0 6px; color: var(--midnight); }
.doc-body p { margin-bottom: 10px; } .doc-body ul, .doc-body ol { margin: 0 0 10px 20px; }
.doc-body table { border-collapse: collapse; width: 100%; margin: 6px 0 12px; font-size: 14px; }
.doc-body th { background: var(--midnight); color: #fff; text-align: left; padding: 6px 10px; }
.doc-body td { padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.doc-body blockquote { margin: 0 0 10px; padding: 8px 14px; background: var(--panel); border-radius: var(--radius-s); }
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
/* the sign-in page: the photograph behind everything, the card over it */
.signin.photo { position: relative; background: #8E939A url(../assets/signin.jpg) center 62% / cover no-repeat; }
.signin.photo::before { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(20,17,40,.18), rgba(20,17,40,.42)); }
.signin.photo .box { position: relative; box-shadow: 0 18px 50px rgba(20,17,40,.28); border-color: rgba(255,255,255,.6); }
.signin.photo .credit { position: absolute; left: 14px; bottom: 10px; font-size: 11px; color: rgba(255,255,255,.8); background: rgba(20,17,40,.35); padding: 3px 8px; border-radius: 4px; }
@media (max-width: 900px) { .signin.photo { background-position: center 40%; } }
.signin .box { width: 100%; max-width: 440px; background: var(--canvas); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.signin .logo { display: block; width: 260px; max-width: 100%; margin: 0 auto 20px; }
.signin .tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.signin .tabs button { flex: 1; padding: 8px; border: 1px solid var(--line-2); background: var(--canvas); border-radius: var(--radius-s); cursor: pointer; }
.signin .tabs button.on { background: var(--midnight); color: #fff; border-color: var(--midnight); }
.signin .ms { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; margin-top: 10px; }
.signin .help { margin-top: 18px; font-size: 13px; color: var(--ink-2); text-align: center; }
.foot { margin-top: 24px; font-size: 12px; color: var(--ink-3); }
.sig { width: 100%; height: 160px; border: 1px dashed var(--line-2); border-radius: var(--radius-s); background: #fff; touch-action: none; }
.progress { display: flex; gap: 4px; margin: 8px 0 16px; } .progress span { flex: 1; height: 5px; border-radius: 3px; background: var(--panel-2); } .progress span.done { background: var(--midnight); } .progress span.cur { background: var(--violet); }
.flagnote { color: var(--warn); font-size: 13px; }
.rows table { width: 100%; border-collapse: collapse; font-size: 13px; } .rows th, .rows td { padding: 4px; text-align: left; } .rows input { width: 100%; padding: 6px 8px; border: 1px solid var(--line-2); border-radius: 6px; }
.action { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 12px; margin-bottom: 10px; display: grid; gap: 8px; }
.action .src { font-size: 13px; color: var(--warn); font-weight: 600; }
.action .grid { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; } .action input, .action textarea { padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 6px; width: 100%; }
.nav-btns { display: flex; justify-content: space-between; margin-top: 12px; }
.breadcrumb { font-size: 13px; color: var(--ink-3); margin-bottom: 12px; } .breadcrumb a { color: var(--ink-2); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { color: var(--ink-2); }
.drop { border: 2px dashed var(--line-2); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--ink-2); background: var(--canvas); }
.drop.over { border-color: var(--violet); background: var(--panel); }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 14px; font-size: 14px; } .kv dt { color: var(--ink-3); } .kv dd { margin: 0; }
.perm-grid th:first-child, .perm-grid td:first-child { position: sticky; left: 0; background: var(--canvas); }
.perm-grid select { padding: 4px 6px; border: 1px solid var(--line-2); border-radius: 6px; font-size: 13px; }
.client-logo { height: 40px; width: auto; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line-2); border-top-color: var(--midnight); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* programme chips in the sidebar */
.progs { padding: 10px 16px 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.progs h3 { width: 100%; margin: 0 0 4px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); font-family: var(--font-head, inherit); }
.progs .chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer; color: var(--ink-2); }
.progs .chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
/* registers */
.reg-item { border-top: 1px solid var(--line); padding: 8px 0; }
.reg-item summary { display: flex; align-items: center; gap: 12px; cursor: pointer; list-style: none; flex-wrap: wrap; }
.reg-item summary::-webkit-details-marker { display: none; }
.reg-ref { font-family: var(--font-head, inherit); font-weight: 700; color: var(--ink-3); min-width: 88px; font-size: 13px; }
.reg-name { flex: 1 1 240px; font-weight: 600; }
.reg-body { padding: 12px 0 6px 100px; }
.stat.on { outline: 2px solid var(--ink); }
a.stat { text-decoration: none; color: inherit; display: block; }
@media (max-width: 760px) { .reg-body { padding-left: 0; } }
@media print {
  .side, .top, .page-head .btn, .no-print, .backdrop, #notice .notice { display: none !important }
  .main { margin: 0 !important; padding: 0 !important; max-width: none }
  body { background: #fff }
  .card { border: 0; box-shadow: none; padding: 0 }
}

/* Allergen matrix */
.print-only { display: none; }
.al.contains { color: #B3261E; } .al.may { color: #8A6D00; }
.al-key { font-weight: 600; display: inline-flex; align-items: center; gap: 4px; margin-right: 14px; } .al-key.contains { color: #B3261E; } .al-key.may { color: #8A6D00; }
.al-legend p { margin: 0 0 8px; } .al-legend p:last-child { margin: 0; }
.al-names { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; } .al-names span { display: inline-flex; align-items: center; gap: 4px; }
.al-matrix th { text-align: center; vertical-align: bottom; } .al-matrix th:first-child { text-align: left; } .al-matrix td:first-child { min-width: 170px; }
.al-th { font-size: 10px; font-weight: 500; color: var(--ink-2); line-height: 1.2; }
.al-cat td { background: var(--panel); font-weight: 600; }
.al-cell { text-align: center; } .al-cell.contains { background: #FBE4E1; } .al-cell.may { background: #FFF3CC; }
.al-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.al-picker label { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius-s); cursor: pointer; font-size: 13px; }
.al-picker label:has(input:checked) { border-color: var(--midnight); background: var(--panel); }
.al-picker input { width: auto; }
.al-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; margin-bottom: 14px; }
.al-card { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 12px 14px; background: var(--canvas); break-inside: avoid; }
.al-card .t { font-weight: 700; margin-bottom: 6px; } .al-icons { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.al-print-head { display: none; align-items: center; gap: 16px; margin-bottom: 12px; } .al-print-head img { max-height: 44px; max-width: 160px; } .al-print-title { font-family: var(--font-head); font-size: 20px; font-weight: 700; }
@media print {
  .print-only { display: block; } .al-print-head { display: flex; }
  .al-page .page-head, .breadcrumb { display: none; }
  .al-wrap { overflow: visible; }
  .al-matrix { font-size: 10px; } .al-matrix td, .al-matrix th { padding: 4px 5px; }
  .al-cell.contains { background: #FBE4E1 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; } .al-cell.may { background: #FFF3CC !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .al-cards { grid-template-columns: 1fr 1fr; }
}
@page { margin: 14mm; }

/* Incident reporting */
.report-btn { justify-content: center; width: 100%; margin-bottom: 14px; }
.side .report-btn { margin: 0 0 12px; }
.public { max-width: 760px; margin: 0 auto; padding: 24px 16px 40px; }
.public-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; } .public-head img { width: 200px; max-width: 60%; }
.public h1 { font-family: var(--font-head); font-size: 28px; margin: 0 0 8px; } .public .intro { color: var(--ink-2); margin-bottom: 16px; }
.public .card { margin-bottom: 14px; } .public .help { font-size: 13px; color: var(--ink-2); }

/* Compliance calendar */
.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; } .cal-head h2 { margin: 0 auto 0 6px; font-size: 20px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 4px 6px; }
.cal-cell { min-height: 92px; background: var(--canvas); border: 1px solid var(--line); border-radius: 6px; padding: 4px; font-size: 12px; } .cal-cell.empty { background: transparent; border-color: transparent; } .cal-cell.today { border-color: var(--midnight); box-shadow: inset 0 0 0 1px var(--midnight); }
.cal-day { font-weight: 600; margin-bottom: 3px; }
.cal-item { display: block; padding: 2px 5px; margin-bottom: 2px; border-radius: 4px; background: var(--panel-2); color: var(--ink); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11px; }
.cal-item.due, .cal-item.warn { background: #FBF0D9; } .cal-item.late { background: #FBE4E1; color: var(--bad); } .cal-item.bad { background: #FBE4E1; } .cal-item.rep { background: var(--midnight); color: #fff; } .cal-item.done { background: #E3F3E8; color: var(--ok); }
.cal-key { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; } .cal-key .cal-item { display: inline-block; margin: 0; }
.cal-row-late td:first-child { color: var(--bad); font-weight: 600; }
@media (max-width: 720px) { .cal-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); } .cal-cell { min-height: 54px; } .cal-item { font-size: 10px; } }
@media print { .cal-head .btn, .page-head .btn, .page-head select, .page-head label { display: none; } .cal-cell { min-height: 70px; } }
.closebox { margin-top: 8px; padding: 10px; background: var(--panel); border-radius: var(--radius-s); min-width: 240px; } .closebox textarea { width: 100%; margin-top: 4px; }

/* Readings */
.rd-grid td, .rd-grid th { text-align: center; } .rd-grid td:first-child, .rd-grid th:first-child { text-align: left; }
.rd-cell.ok { background: #E3F3E8; } .rd-cell.bad { background: #FBE4E1; color: var(--bad); font-weight: 600; } .rd-cell.miss { background: var(--panel-2); }

/* QR labels: Avery L7160, 21 per sheet */
.labels { display: grid; grid-template-columns: repeat(3, 63.5mm); column-gap: 2.5mm; row-gap: 0; }
.label { width: 63.5mm; height: 38.1mm; box-sizing: border-box; padding: 3mm; display: flex; gap: 3mm; align-items: center; border: 1px dashed var(--line-2); break-inside: avoid; }
.label .qr svg { display: block; width: 28mm; height: 28mm; }
.label .txt { flex: 1; min-width: 0; font-size: 9pt; line-height: 1.25; } .label .t { font-weight: 700; font-size: 10pt; } .label .s, .label .o { color: var(--ink-2); } .label .c { font-size: 7pt; color: var(--ink-3); margin-top: 2mm; }
@media print { .labels { grid-template-columns: repeat(3, 63.5mm); } .label { border: 0; } }
@media (max-width: 720px) { .labels { grid-template-columns: 1fr; } }

/* Kiosk */
.kiosk { max-width: 900px; } .kiosk h1 { font-size: 32px; margin-bottom: 4px; }
.kiosk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 18px; }
.kiosk-tile { display: block; padding: 26px 22px; background: var(--canvas); border: 2px solid var(--line-2); border-radius: var(--radius); text-decoration: none; color: var(--ink); min-height: 120px; }
.kiosk-tile:first-child { background: var(--amber); border-color: var(--amber); }
.kiosk-tile .t { font-family: var(--font-head); font-size: 22px; font-weight: 700; } .kiosk-tile .s { color: var(--ink-2); margin-top: 6px; }
[hidden] { display: none !important; }

/* Competence matrix, evidence pack, trends */
.cm-grid th { white-space: normal; max-width: 120px; } .cm-cell { text-align: center; font-size: 12px; } .cm-cell a { text-decoration: none; color: inherit; display: block; padding: 4px; border-radius: 4px; }
.cm-cell.ok a { background: #E3F3E8; color: var(--ok); } .cm-cell.warn a { background: #FBF0D9; color: var(--warn); } .cm-cell.bad a { background: #FBE4E1; color: var(--bad); } .cm-cell.none a { color: var(--ink-3); }
.pack-rec { break-inside: avoid; } .pack-rec h2 { margin-bottom: 2px; }
.trend { width: 100%; height: auto; display: block; }

.search-card { padding: 10px 12px; margin-bottom: 14px; } .search-card input[type=search] { width: 100%; font-size: 15px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-s); background: var(--canvas); }
