/* Raqeeb: mobile-first, high contrast for use outdoors in sunlight. */
:root {
  --ink: #0d1b2a; --muted: #44515f; --bg: #f4f6f8; --card: #fff; --line: #c9d1d9;
  --brand: #0b5394; --brand-ink: #fff; --ok: #1b5e20; --bad: #b71c1c; --obs: #0d47a1; --na: #555;
  --low: #2e7d32; --medium: #f9a825; --high: #ef6c00; --critical: #c62828;
  --radius: 10px; --tap: 52px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); }
.wrap { max-width: 860px; margin: 0 auto; padding: 16px; }
.topbar { background: var(--brand); color: var(--brand-ink); padding: 10px 16px; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.topbar a, .topbar .link { color: var(--brand-ink); text-decoration: none; font-weight: 600; }
.brand { font-size: 1.25rem; }
.brand-ar { font-size: 1.35rem; }
.nav { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 24px 16px; }
h1 { font-size: 1.5rem; margin: .4em 0 .6em; }
h2 { font-size: 1.2rem; margin: 1.2em 0 .5em; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; }
.narrow { max-width: 480px; margin: 24px auto; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.inline { display: inline; margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }

/* Forms */
label { display: block; font-weight: 600; margin: 12px 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=search], input[type=number], input:not([type]), select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; font: inherit; color: var(--ink);
  background: #fff; border: 2px solid #7a8794; border-radius: 8px;
}
textarea { min-height: 90px; }
input:focus, select:focus, textarea:focus, button:focus, .btn:focus { outline: 3px solid #ffb300; outline-offset: 2px; }
.helptext, .help { display: block; color: var(--muted); font-size: .88rem; margin-top: 4px; }
.errorlist { color: var(--bad); font-weight: 600; padding-left: 18px; margin: 6px 0; }
.form-errors { border-left: 5px solid var(--bad); background: #fdecea; padding: 10px 12px; border-radius: 6px; }
ul.choices, div.choices, form ul:not(.errorlist) { list-style: none; padding: 0; margin: 0; }

/* Buttons */
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap); padding: 10px 18px;
  font: inherit; font-weight: 700; border-radius: 8px; border: 2px solid var(--brand); background: #fff; color: var(--brand); cursor: pointer; text-decoration: none; }
.btn-primary, button[type=submit]:not(.link):not(.btn-secondary):not(.btn-danger) { background: var(--brand); color: #fff; }
.btn-danger { border-color: var(--bad); color: var(--bad); background: #fff; }
.btn-block { display: flex; width: 100%; margin-top: 12px; }
button.link { background: none; border: 0; padding: 0; min-height: 0; font-weight: 600; text-decoration: underline; color: inherit; }

/* Big segmented choices (result, likelihood, severity). Django renders
   <div id="id_x"><div><label><input> text</label></div>...</div> */
.seg div[id^="id_"] { display: flex; flex-wrap: wrap; gap: 8px; }
.seg div[id^="id_"] > div { flex: 1 1 0; min-width: 52px; }
.seg div[id^="id_"] label { margin: 0; display: flex; align-items: center; justify-content: center; min-height: var(--tap); border: 2px solid #7a8794; border-radius: 8px; background: #fff; cursor: pointer; padding: 6px; text-align: center; font-weight: 700; }
.seg div[id^="id_"] input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg div[id^="id_"] label:has(input:checked) { background: var(--ink); color: #fff; border-color: var(--ink); }
.seg div[id^="id_"] label:has(input:focus-visible) { outline: 3px solid #ffb300; }
.checks div[id^="id_"] label, .checks > label:has(input) { font-weight: 500; display: flex; gap: 10px; align-items: flex-start; border: 2px solid var(--line); border-radius: 8px; padding: 12px; margin: 8px 0; background: #fff; }
.checks input[type=checkbox] { width: 24px; height: 24px; flex: none; margin-top: 2px; }
.checks div[id^="id_"] label:has(input:checked), .checks > label:has(input:checked) { border-color: var(--brand); background: #e8f0fb; }
input[type=checkbox] { width: 22px; height: 22px; }

/* Badges and risk colours */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .82rem; font-weight: 700; border: 1px solid transparent; white-space: nowrap; }
.b-draft { background: #fff3cd; color: #6d4c00; border-color: #c9a227; }
.b-verified { background: #e3f4e5; color: var(--ok); border-color: var(--ok); }
.b-signed { background: #e3f4e5; color: var(--ok); }
.b-pass { background: #e3f4e5; color: var(--ok); }
.b-fail { background: #fdecea; color: var(--bad); }
.b-observation { background: #e3edfb; color: var(--obs); }
.b-na { background: #eee; color: var(--na); }
.b-demo { background: #222; color: #fff; }
.risk { display: inline-block; min-width: 2.4em; text-align: center; padding: 2px 8px; border-radius: 6px; font-weight: 800; color: #fff; }
.risk-low { background: var(--low); }
.risk-medium { background: var(--medium); color: #1a1a1a; }
.risk-high { background: var(--high); }
.risk-critical { background: var(--critical); }
.scorebox { margin-top: 12px; padding: 12px; border-radius: 8px; font-size: 1.15rem; font-weight: 800; border: 2px solid var(--line); background: #fff; }

/* Lists */
.list { list-style: none; padding: 0; margin: 0; }
.list > li { border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.list a.item, .list .item { display: block; padding: 12px 4px; color: inherit; text-decoration: none; }
.list a.item:hover { background: #eef3f8; }
.item-title { font-weight: 700; }
.counts { display: flex; flex-wrap: wrap; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip { padding: 8px 12px; border: 2px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--ink); background: #fff; font-weight: 600; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.photos { display: flex; flex-wrap: wrap; gap: 8px; }
.photos figure { margin: 0; width: 140px; }
.photos img { width: 140px; height: 105px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; }
.photos figcaption { font-size: .8rem; color: var(--muted); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-wrap { overflow-x: auto; }
pre.official { white-space: pre-wrap; font: inherit; background: #f7f7f2; border-left: 4px solid #8d6e63; padding: 10px 12px; margin: 8px 0; }

/* Messages */
.msg { padding: 12px 14px; border-radius: 8px; margin: 0 0 10px; font-weight: 600; border-left: 6px solid var(--brand); background: #e8f0fb; }
.msg-success { border-color: var(--ok); background: #e3f4e5; }
.msg-error { border-color: var(--bad); background: #fdecea; }
.msg-warning { border-color: #c9a227; background: #fff3cd; }

/* Signature pad */
.sigpad { width: 100%; height: 200px; border: 2px dashed #7a8794; border-radius: 8px; background: #fff; touch-action: none; display: block; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }
.hidden { display: none !important; }
@media (min-width: 700px) { .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; } }

/* Never let long codes (fingerprints, URLs) push the page wider than the phone. */
code, .wrap-anywhere { overflow-wrap: anywhere; word-break: break-all; }
.wrap, .card { min-width: 0; overflow-wrap: anywhere; }
.sigpreview { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.seg-2x2 div[id^="id_"] > div { flex: 1 1 40%; }
