/* NATIONAL-OB+PE - Five Points
   Zambian national colours appear ONLY as a thin flag-order stripe and a deep-green accent.
   Status/severity never relies on those hues: it uses labels, symbols and weight so a green or
   red stripe is never mistaken for "ok" or "critical". */
:root {
  --zm-green: #198A00;
  --zm-red: #DE2010;
  --zm-black: #000000;
  --zm-orange: #EF7D00;
  --green-deep: #0f5c00;
  --ink: #1b2430;
  --ink-soft: #55606e;
  --line: #d9dee5;
  --bg: #f5f7f9;
  --panel: #ffffff;
  --slate: #26323f;
  --focus: #0b5cad;
  --warn-bg: #fff4e0;
  --err-bg: #fdecea;
  --ok-bg: #e8f5e9;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink); background: var(--bg); line-height: 1.45;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--green-deep); }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* the flag-order stripe: green field, then red / black / orange as on the fly end of the flag */
.flagbar {
  height: 5px; width: 100%;
  background: linear-gradient(90deg,
    var(--zm-green) 0 70%, var(--zm-red) 70% 80%, var(--zm-black) 80% 90%, var(--zm-orange) 90% 100%);
}

.envbanner {
  background: var(--slate); color: #fff; text-align: center; font-size: .78rem;
  letter-spacing: .08em; padding: .2rem .5rem; text-transform: uppercase;
}
header.top { background: var(--panel); border-bottom: 1px solid var(--line); }
.top-inner {
  max-width: 1200px; margin: 0 auto; padding: .7rem 1rem;
  display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; align-items: center; justify-content: space-between;
}
.brand { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); }
.brand strong { font-size: 1.25rem; letter-spacing: .02em; }
.brand span { font-size: .76rem; color: var(--ink-soft); }
nav.main { display: flex; flex-wrap: wrap; gap: .25rem; }
nav.main a {
  text-decoration: none; color: var(--ink); padding: .4rem .75rem; border-radius: 6px; font-weight: 500;
  border-bottom: 3px solid transparent;
}
nav.main a:hover { background: var(--bg); }
nav.main a.active { border-bottom-color: var(--zm-green); color: var(--green-deep); font-weight: 700; }
.who { font-size: .82rem; color: var(--ink-soft); display: flex; gap: .75rem; align-items: center; flex-basis: 100%; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: .4rem; }
.who form { margin: 0; }

main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem 2rem; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; }
h3 { font-size: .95rem; margin: 1rem 0 .4rem; }
.sub { color: var(--ink-soft); margin: 0 0 1rem; }
.pagehead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: .5rem; margin-bottom: .75rem; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.q { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); margin: 0 0 .35rem; font-weight: 700; }
.big { font-size: 2rem; font-weight: 700; line-height: 1; }
.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; word-break: break-all; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .5rem .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .75rem; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-soft); background: #fafbfc; }
tr:hover td { background: #fafcfa; }
.tablewrap { overflow-x: auto; }

.btn, button {
  display: inline-block; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--green-deep); color: #fff; border: 1px solid var(--green-deep); border-radius: 6px; padding: .45rem .9rem;
}
.btn:hover, button:hover { background: #0a4700; color: #fff; }
.btn.ghost, button.ghost { background: #fff; color: var(--green-deep); }
.btn.ghost:hover, button.ghost:hover { background: var(--ok-bg); color: var(--green-deep); }
.btn.warn, button.warn { background: #fff; color: #7a3b00; border-color: #7a3b00; }
.btn.small, button.small { padding: .25rem .6rem; font-size: .85rem; }

form.stack div, form .field { margin-bottom: .75rem; }
form label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .2rem; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=datetime-local],
input[type=file], select, textarea {
  width: 100%; font: inherit; padding: .45rem .55rem; border: 1px solid #aab3be; border-radius: 6px; background: #fff;
}
input[type=checkbox] { margin-right: .4rem; }
.helptext, form .helptext { display: block; color: var(--ink-soft); font-size: .8rem; font-weight: 400; margin-top: .15rem; }
.errorlist { list-style: none; padding: 0; margin: .2rem 0; color: #8a1c10; font-size: .85rem; font-weight: 600; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; align-items: end; }
.filters label { font-size: .75rem; }
.filters select, .filters input { width: auto; min-width: 9rem; }

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: .6rem .8rem; border-radius: 6px; margin-bottom: .4rem; border: 1px solid var(--line); background: #fff; }
.messages li.success { background: var(--ok-bg); border-color: #9ccc9f; }
.messages li.error { background: var(--err-bg); border-color: #e3a29b; font-weight: 600; }
.messages li.warning { background: var(--warn-bg); border-color: #e8c27a; }

/* severity: label + triangles + weight, not hue */
/* severity: colour AND label AND triangles (never colour alone). S1 blue-grey, S2 yellow, S3 orange, S4 red, S5 deep purple */
.sev { display: inline-block; font-size: .78rem; font-weight: 700; padding: .12rem .45rem; border-radius: 4px; border: 1.5px solid #5b7fa6; color: #1f3d5c; background: #e3edf7; white-space: nowrap; }
.sev-2 { background: #fff3b0; border-color: #b08900; color: #5c4700; }
.sev-3 { background: #ffd9a8; border: 2px solid #c25e00; color: #5e2a00; }
.sev-4 { background: #c62828; color: #fff; border: 2px solid #8e1b1b; }
.sev-5 { background: #4a148c; color: #fff; border: 2px solid #2d0a57; letter-spacing: .02em; }
.pill { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: #eef1f4; border: 1px solid var(--line); white-space: nowrap; }
.pill.overdue { background: var(--warn-bg); border-color: #7a3b00; color: #7a3b00; font-weight: 700; }

/* evidence confidence: the number carries the meaning */
.lvl { display: inline-block; font-size: .78rem; padding: .1rem .45rem; border-radius: 4px; border: 1px solid #8b95a1; background: #fff; white-space: nowrap; }
.lvl-n { font-weight: 800; margin-right: .25rem; }
.lvl-0 { border: 2px dashed #7a3b00; color: #7a3b00; }
.lvl-4, .lvl-5 { border-color: var(--green-deep); border-width: 2px; }

.exc { list-style: none; margin: 0; padding: 0; }
.exc li { display: grid; grid-template-columns: 11.5rem 1fr; gap: .25rem .75rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.exc .kind { font-weight: 700; font-size: .85rem; }
.exc .why { color: var(--ink-soft); font-size: .88rem; }
@media (max-width: 640px) { .exc li { grid-template-columns: 1fr; } }

meter { width: 100%; height: .9rem; }
.kv { display: grid; grid-template-columns: 11rem 1fr; gap: .3rem .75rem; margin: 0; }
.kv dt { font-weight: 600; color: var(--ink-soft); font-size: .88rem; }
.kv dd { margin: 0; }
@media (max-width: 640px) { .kv { grid-template-columns: 1fr; } }
details.op { border: 1px solid var(--line); border-radius: 6px; padding: .5rem .75rem; margin-bottom: .5rem; background: #fff; }
details.op > summary { cursor: pointer; font-weight: 600; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: .4rem 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.qr svg { width: 220px; height: 220px; background: #fff; border: 1px solid var(--line); padding: 6px; }

footer.site { margin-top: auto; background: var(--panel); }
footer.site .foot-inner { max-width: 1200px; margin: 0 auto; padding: .8rem 1rem; text-align: center; font-size: .85rem; }
footer.site a { color: var(--ink-soft); text-decoration: none; }
footer.site a:hover { color: var(--green-deep); text-decoration: underline; }

.login-wrap { max-width: 420px; margin: 2rem auto; }

@media print {
  nav.main, .who, .envbanner, .btn, button, details.op { display: none !important; }
  body { background: #fff; }
  .panel { border: 1px solid #999; break-inside: avoid; }
}

[hidden] { display: none !important; }
footer.site .foot-inner button { margin-top: .4rem; }

/* risk bands: colour AND score AND label AND triangles, like severity */
.rb { display: inline-block; font-size: .78rem; font-weight: 700; padding: .12rem .45rem; border-radius: 4px; border: 1.5px solid #5b7fa6; color: #1f3d5c; background: #e3edf7; white-space: nowrap; }
.rb-2 { background: #fff3b0; border-color: #b08900; color: #5c4700; }
.rb-3 { background: #ffd9a8; border: 2px solid #c25e00; color: #5e2a00; }
.rb-4 { background: #c62828; color: #fff; border: 2px solid #8e1b1b; }
.pill.esc { font-weight: 700; }
.pill.esc-1 { background: var(--warn-bg); border-color: #7a3b00; color: #7a3b00; }
.pill.esc-2 { background: #ffd9a8; border-color: #c25e00; color: #5e2a00; }
.pill.esc-3 { background: #c62828; border-color: #8e1b1b; color: #fff; }

/* 5 x 5 risk heat map */
table.heat { width: auto; border-collapse: separate; border-spacing: 3px; }
table.heat th { background: none; text-transform: none; letter-spacing: 0; font-size: .75rem; padding: .2rem .4rem; border: 0; }
table.heat td { padding: 0; border: 0; }
table.heat td a, table.heat td span.cell { display: flex; align-items: center; justify-content: center; width: 3.4rem; height: 2.6rem; border-radius: 5px;
  font-weight: 800; text-decoration: none; border: 1.5px solid transparent; }
.hc-1 { background: #e3edf7; color: #1f3d5c; border-color: #5b7fa6 !important; }
.hc-2 { background: #fff3b0; color: #5c4700; border-color: #b08900 !important; }
.hc-3 { background: #ffd9a8; color: #5e2a00; border-color: #c25e00 !important; }
.hc-4 { background: #c62828; color: #fff; border-color: #8e1b1b !important; }
.hc-zero { opacity: .55; font-weight: 400; }
.legend { display: flex; flex-wrap: wrap; gap: .5rem 1rem; font-size: .82rem; margin-top: .5rem; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { padding: .35rem 0; border-bottom: 1px dashed var(--line); display: flex; gap: .75rem; align-items: center; justify-content: space-between; }
.checklist form { margin: 0; }

/* map */
#map { height: 62vh; min-height: 380px; border: 1px solid var(--line); border-radius: 8px; background: #eef3ee; }
.maplayers { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; margin: .5rem 0; font-size: .9rem; }
.maplayers label { display: inline-flex; align-items: center; font-weight: 500; margin: 0; }
.pin { display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .75rem; color: #fff; border: 2px solid #fff; box-shadow: 0 0 2px #000; }
.pin-prog { background: #0f5c00; border-radius: 4px; }
.pin-risk { border-radius: 50%; background: #5b7fa6; }
.pin-risk-2 { background: #b08900; }
.pin-risk-3 { background: #c25e00; }
.pin-risk-4 { background: #c62828; }
.leaflet-container a { color: #0f5c00; }
.leaflet-tooltip.refname { background: transparent; border: 0; box-shadow: none; color: #55606e; font-size: .72rem; padding: 0; }
.leaflet-tooltip.refname:before { display: none; }
.tablewrap td:first-child { white-space: nowrap; }
