:root {
  --bg: #f7f7f5; --panel: #ffffff; --ink: #1c1d1f; --muted: #6b6f76; --line: #e3e3df;
  --pass: #15803d; --caution: #c2410c; --fail: #b91c1c; --unverified: #6b7280;
  --accent: #0f766e;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg);
       display: flex; flex-direction: column; }
#demo-banner { background: #fef3c7; color: #78350f; padding: 6px 16px; font-weight: 600; text-align: center; border-bottom: 1px solid #fcd34d; }
header { display: flex; align-items: baseline; gap: 12px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
header h1 { font-size: 17px; margin: 0; }
header .sub { color: var(--muted); font-size: 12.5px; }
main { flex: 1; display: grid; grid-template-columns: 360px minmax(0, 1fr); min-height: 0; position: relative; }

#sidebar { min-width: 0; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.controls { padding: 12px 14px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.field { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.field input, .field select { font: inherit; color: var(--ink); padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; width: 100%; }
.field input[type="checkbox"] { width: auto; padding: 0; }
.row { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 8px; }
.pair { display: flex; gap: 4px; min-width: 0; }
.pair input { min-width: 0; }
.status-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.status-filters label { display: flex; align-items: center; gap: 3px; cursor: pointer; }
#source-filters { gap: 6px 10px; }
#source-filters label { color: var(--ink); }
.counts { font-size: 12px; color: var(--muted); }

.pill { flex: none; display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; color: #fff; text-transform: capitalize; }
.pill.pass { background: var(--pass); } .pill.caution { background: var(--caution); }
.pill.fail { background: var(--fail); } .pill.unverified { background: var(--unverified); }
.src { display: inline-block; padding: 0 6px; border-radius: 4px; background: #eef2f1; color: #134e4a; font-size: 12px; font-weight: 600; }

#list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
#list li { padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; display: grid; grid-template-columns: minmax(0, 1fr); gap: 3px; }
#list li:hover { background: #f2f7f6; }
#list li.active { background: #e6f2f0; box-shadow: inset 3px 0 0 var(--accent); }
#list .top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
#list .title { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#list .meta { color: var(--muted); font-size: 12.5px; }
#list .score { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent); }

#map-wrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; }
.map-tools { position: absolute; top: 10px; right: 10px; z-index: 500; display: flex; gap: 6px; }
.map-tools button { font: inherit; font-weight: 600; padding: 7px 11px; border-radius: 6px; border: 1px solid var(--line); background: #fff; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.map-tools button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
#legend summary { font-weight: 700; cursor: pointer; }
#legend details > div { display: grid; gap: 3px; margin-top: 4px; }
#legend { position: absolute; left: 10px; bottom: 18px; z-index: 500; background: rgba(255,255,255,.95); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; display: grid; gap: 3px; }
#legend label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.leaflet-container.probing { cursor: crosshair; }

#detail { position: absolute; top: 0; right: 0; bottom: 0; width: 400px; max-width: 100%; z-index: 800; background: var(--panel);
          border-left: 1px solid var(--line); overflow-y: auto; padding: 16px; box-shadow: -4px 0 16px rgba(0,0,0,.06); }
#detail .close { position: absolute; top: 8px; right: 10px; font-size: 22px; border: 0; background: none; cursor: pointer; color: var(--muted); }
#detail h2 { font-size: 16px; margin: 0 28px 4px 0; }
#detail h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 6px; }
#detail table { width: 100%; border-collapse: collapse; font-size: 13px; }
#detail td, #detail th { padding: 5px 4px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
#detail td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
#detail .facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
#detail .fact { background: var(--bg); border-radius: 8px; padding: 8px; }
#detail .fact b { display: block; font-size: 15px; }
#detail .fact span { font-size: 12px; color: var(--muted); }
#detail ul.reasons { padding-left: 18px; margin: 6px 0; }
#detail ul.checklist { padding-left: 18px; font-size: 13px; }
#detail .note { font-size: 12px; color: var(--muted); }
#detail .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
#detail .actions a, #detail .actions button { font: inherit; font-size: 12.5px; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); text-decoration: none; cursor: pointer; }

.marker { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; border: 2.5px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.35), 0 1px 4px rgba(0,0,0,.35); }
.marker.pass { background: var(--pass); } .marker.caution { background: var(--caution); }
.marker.fail { background: var(--fail); } .marker.unverified { background: var(--unverified); }
.marker.sel { width: 26px; height: 26px; box-shadow: 0 0 0 3px var(--accent), 0 1px 6px rgba(0,0,0,.4); }

@media (max-width: 800px) {
  main { grid-template-columns: minmax(0, 1fr); grid-template-rows: 55vh auto; }
  #map-wrap { grid-row: 1; }
  #sidebar { grid-row: 2; border-right: 0; }
  #detail { position: fixed; top: auto; height: 65vh; width: 100%; border-left: 0; border-top: 1px solid var(--line); }
  header .sub { display: none; }
  .map-tools { left: 56px; justify-content: flex-end; flex-wrap: wrap; }
  .map-tools button { padding: 6px 9px; font-size: 12.5px; }
}

/* --- user menu, login, admin --- */
.usermenu { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); }
.usermenu a { color: var(--accent); text-decoration: none; font-weight: 600; }
.usermenu form { margin: 0; }
.linkbtn { font: inherit; border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; }
.role { display: inline-block; padding: 0 6px; border-radius: 4px; background: #eef2f1; color: #134e4a; font-size: 12px; font-weight: 600; text-transform: capitalize; }
.btn { font: inherit; font-size: 13px; padding: 7px 12px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn:disabled { opacity: .55; cursor: default; }
.login-wrap { flex: 1; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 340px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 22px; display: grid; gap: 12px; }
.login h1 { font-size: 18px; margin: 0; }
.error { background: #fef2f2; color: var(--fail); border: 1px solid #fecaca; border-radius: 6px; padding: 8px 10px; font-size: 13px; }
.ok { background: #f0fdf4; color: var(--pass); border: 1px solid #bbf7d0; border-radius: 6px; padding: 8px 10px; font-size: 13px; }
body.admin { overflow: auto; }
.admin-main { display: block; max-width: 1100px; width: 100%; margin: 0 auto; padding: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: grid; gap: 10px; align-content: start; min-width: 0; }
.card h2 { font-size: 14px; margin: 0; }
.card p { margin: 0; }
.muted { color: var(--muted); font-size: 12.5px; }
.admin-main h2.section { font-size: 15px; margin: 24px 0 10px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.tbl th, .tbl td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { font-size: 12px; color: var(--muted); font-weight: 600; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover { background: #f3f4f2; }
.tbl-wrap { overflow-x: auto; }
.st { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; color: #fff; text-transform: capitalize; background: var(--unverified); }
.st.done { background: var(--pass); } .st.failed { background: var(--fail); } .st.running { background: var(--accent); }
.joblog { background: #111827; color: #e5e7eb; font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 12px; border-radius: 8px; max-height: 420px; overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 0; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 13px; }
.checks label { display: flex; gap: 4px; align-items: center; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.inline .field { flex: 1 1 140px; }
@media (max-width: 700px) { .usermenu .who { display: none; } }

/* --- accessibility + touch (UI review items 3, 5, 6) --- */
:where(a, button, input, select, summary, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
#list li:focus-visible { outline-offset: -3px; }
.map-tools button.on:focus-visible, .btn.primary:focus-visible { outline-color: var(--ink); }
.marker svg { width: 13px; height: 13px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.leaflet-container.placing { cursor: crosshair; }
#list li.empty { cursor: default; color: var(--muted); padding: 18px 14px; line-height: 1.5; }
#list li.empty b { color: var(--ink); }
#list li.empty a { color: var(--accent); font-weight: 600; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 2000; background: var(--accent); color: #fff; padding: 8px 12px; border-radius: 6px; font-weight: 600; }
.skip:focus { top: 8px; }
/* Comfortable targets for touch screens (40px+) */
.map-tools button, #detail .actions a, #detail .actions button, .btn { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
#detail .close { width: 40px; height: 40px; top: 4px; right: 4px; display: grid; place-items: center; border-radius: 6px; }
.field input, .field select { min-height: 38px; }
.status-filters label, #legend label { min-height: 28px; }
.linkbtn { min-height: 32px; }
/* Dialogs (admin) */
dialog.dlg { border: 1px solid var(--line); border-radius: 10px; padding: 18px; width: min(380px, calc(100vw - 32px)); color: var(--ink); }
dialog.dlg::backdrop { background: rgba(17, 24, 39, .45); }
dialog.dlg form { display: grid; gap: 12px; margin: 0; }
dialog.dlg h2 { font-size: 15px; margin: 0; }
dialog.dlg .buttons { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.btn.danger { background: var(--fail); border-color: var(--fail); color: #fff; font-weight: 600; }
.field .hint { color: var(--muted); font-size: 12px; }
.field .err { color: var(--fail); font-size: 12.5px; }
