/* Utilitarian tool UI: scanned and operated, not read. Single light theme,
   every colour explicit. Severity colour is semantic and never the accent. */
:root {
  --bg: #eef2f7;
  --panel: #ffffff;
  --sunken: #f5f8fc;
  --line: #dbe3ed;
  --line-2: #c3cfdd;
  --ink: #13202f;
  --ink-2: #3c4c60;
  --muted: #5f7186;
  --accent: #2563eb;
  --accent-soft: #e8f0fe;

  --p1: #d0342c;  /* urgent */
  --p2: #d97706;  /* high   */
  --p3: #2f6fd0;  /* normal */
  --p4: #7a8a9c;  /* low    */
  --done: #17803d;

  --r: 8px;
}
* { box-sizing: border-box; }
/* Rules below set `display` on elements that are toggled with the `hidden`
   attribute, and a class beats the user-agent's [hidden] rule. */
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
  display: flex; flex-direction: column; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 3px; }
time, .num { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- top bar */
header {
  display: flex; align-items: center; gap: 10px; flex: none;
  padding: 9px 14px; background: var(--panel); border-bottom: 1px solid var(--line);
}
header h1 { font-size: 14.5px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
header h1 small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); letter-spacing: 0; }
.spacer { flex: 1; }

select, input[type=search], input[type=text], input[type=date], textarea {
  padding: 6px 9px; border: 1px solid var(--line-2); border-radius: 7px;
  background: #fff; outline-offset: -1px;
}
input::placeholder, textarea::placeholder { color: #9aa8b8; }
input[type=search] { width: 210px; }

.btn {
  padding: 6px 11px; border: 1px solid var(--line-2); border-radius: 7px;
  background: #fff; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--sunken); border-color: var(--muted); }
.btn .plus { color: var(--muted); font-weight: 700; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn.on .plus { color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled, .ghost:disabled { opacity: .5; cursor: default; filter: none; }
.btn.primary:hover { filter: brightness(1.07); border-color: var(--accent); }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
a.btn { text-decoration: none; color: var(--ink); display: inline-block; }

/* ---------------------------------------------------------------- layout */
main { flex: 1; display: flex; min-height: 0; }

/* ---------------------------------------------------------------- overview */
/* The front page, before any one plan is chosen: the headline counts, then the
   work itself with the worst of it at the top. No charts — there is no history
   to plot, only what is outstanding right now. */
.dash { flex: 1; overflow-y: auto; background: var(--bg); }
.dash-inner { max-width: 880px; margin: 0 auto; padding: 22px 18px 44px; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.tile {
  display: grid; gap: 1px; justify-items: start; text-align: left; cursor: pointer;
  padding: 11px 13px; background: var(--panel);
  border: 1px solid var(--line); border-left: 3px solid var(--line-2);
  border-radius: var(--r);
}
.tile:hover { border-color: var(--line-2); }
.tile.on { border-color: var(--accent); background: var(--accent-soft); }
/* Proportional figures: tabular-nums gives every digit the width of a zero,
   which reads loose at this size. Alignment matters in columns, not here. */
.tile b { font-size: 25px; font-weight: 650; line-height: 1.15; letter-spacing: -.02em; }
.tile span { font-size: 12px; color: var(--muted); }
/* Severity keeps its meaning here: the colour never travels without its word. */
.tile.p1 { border-left-color: var(--p1); } .tile.p1 b { color: var(--p1); }
.tile.p2 { border-left-color: var(--p2); } .tile.p2 b { color: var(--p2); }
.tile.on, .tile.on:hover { border-left-color: var(--accent); }

/* The overview's first heading follows the tiles, so it keeps its gap — the
   general rule closes it for a panel that starts with one. */
.dash .sec, .dash .sec:first-of-type { margin: 22px 0 8px; }
.dash .sec .chip-clear {
  font-size: 11px; letter-spacing: 0; text-transform: none; cursor: pointer;
  color: var(--accent); background: var(--accent-soft);
  border: 1px solid #cfe0fd; border-radius: 20px; padding: 1px 8px;
}
.dash .sec .chip-clear:hover { background: #dbe8fd; }

/* ------------------------------------------------------------ estate map */
/* Where the buildings actually stand. Sized to be read at a glance and scrolled
   past — it is one band of the overview, not the point of it. */
.dash-map {
  height: 270px; margin-top: 12px; overflow: hidden;
  background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r);
  /* Leaflet stacks its panes up to 700 and its controls at 1000, and its own
     container makes no stacking context — so without this they compete with
     the whole page and paint straight through the administration sheet. */
  isolation: isolate;
}
.leaflet-container { font: inherit; background: var(--sunken); }
.leaflet-container a { color: var(--accent); }

/* The same teardrop as on a plan, so a building reads as a marked place. */
.mappin {
  display: grid; place-items: center; width: 26px; height: 26px;
  background: var(--p3); border: 2px solid #fff; border-radius: 50% 50% 50% 3px;
  transform: rotate(-45deg); box-shadow: 0 2px 6px rgba(19,32,47,.45);
}
.mappin b {
  transform: rotate(45deg); color: #fff;
  font: 700 11px/1 -apple-system, "Segoe UI", Roboto, sans-serif;  /* never the <i>'s italic */
}
.mappin.p1 { background: var(--p1); } .mappin.p2 { background: var(--p2); }
.mappin.p3 { background: var(--p3); } .mappin.p4 { background: var(--p4); }
.mappin.clear { background: var(--done); }
/* The picker's marker says "here", not how much work is waiting. */
.mappin.here { background: var(--accent); }

.leaflet-popup-content-wrapper { border-radius: var(--r); box-shadow: 0 4px 18px rgba(19,32,47,.2); }
.leaflet-popup-content { margin: 10px 12px; display: grid; gap: 3px; font-size: 13px; }
.leaflet-popup-content b { font-size: 13.5px; color: var(--ink); }
.leaflet-popup-content span { font-size: 12px; color: var(--muted); }
.leaflet-popup-content .btn { justify-self: start; margin-top: 5px; }

/* The picker an administrator places a building with, inside the admin sheet. */
.pick-map {
  height: 260px; margin: 8px 0; overflow: hidden;
  border: 1px solid var(--line-2); border-radius: var(--r);
  isolation: isolate;          /* the same containment, inside the sheet */
}
.dash .row-card { padding: 10px 12px 10px 14px; }
.dash .empty { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
@media (max-width: 620px) { .tiles { grid-template-columns: repeat(2, 1fr); } }

#stage {
  flex: 1; position: relative; overflow: hidden;
  background: #e3e9f1; cursor: grab; touch-action: none;
}
#stage.panning { cursor: grabbing; }
#stage.adding  { cursor: crosshair; }
#canvas { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
#plan {
  display: block; user-select: none; -webkit-user-drag: none;
  background: #fff; box-shadow: 0 2px 22px rgba(19,32,47,.16);
}

.zoombar {
  position: absolute; left: 12px; bottom: 12px; display: flex; gap: 6px;
  background: rgba(255,255,255,.95); padding: 6px; border-radius: 9px;
  border: 1px solid var(--line); box-shadow: 0 2px 10px rgba(19,32,47,.1);
}
.hint {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(19,32,47,.92); color: #fff; padding: 7px 14px;
  border-radius: 20px; font-size: 12.5px; pointer-events: none;
}

/* ---------------------------------------------------------------- pins */
.pin {
  position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px;
  border-radius: 50% 50% 50% 3px; transform: rotate(-45deg) scale(var(--inv, 1));
  transform-origin: center; background: var(--p3); border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(19,32,47,.4); cursor: pointer;
  display: grid; place-items: center;
}
.pin span { transform: rotate(45deg); color: #fff; font-size: 11px; font-weight: 700; }
.pin.p1 { background: var(--p1); } .pin.p2 { background: var(--p2); }
.pin.p3 { background: var(--p3); } .pin.p4 { background: var(--p4); }
.pin.clear { background: var(--done); }
.pin.sel { outline: 3px solid rgba(37,99,235,.5); outline-offset: 2px; z-index: 5; }
.pin.dim { opacity: .22; }
.pin.urgent { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 2px 6px rgba(19,32,47,.4), 0 0 0 7px rgba(208,52,44,.18); } }
@media (prefers-reduced-motion: reduce) { .pin.urgent { animation: none; } }

/* What a pin cannot say for itself: which place it marks. It lives in the stage
   rather than the canvas, so zooming the plan does not zoom the label. */
.pin-tip {
  position: absolute; z-index: 6; pointer-events: none; max-width: 260px;
  padding: 6px 9px; border-radius: 7px;
  background: rgba(19,32,47,.94); color: #fff;
  font-size: 12.5px; line-height: 1.35;
  box-shadow: 0 2px 10px rgba(19,32,47,.3);
}
.pin-tip b { display: block; font-weight: 600; }
.pin-tip span { color: #b3c1d2; font-size: 11.5px; }

/* ---------------------------------------------------------------- sidebar */
aside {
  width: 400px; flex: none; background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.tabs button {
  flex: 1; padding: 10px; background: none; border: 0;
  border-bottom: 2px solid transparent; cursor: pointer;
  color: var(--muted); font-weight: 550;
}
.tabs button:hover { color: var(--ink-2); }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.panel { flex: 1; overflow-y: auto; padding: 14px; }
.empty { color: var(--muted); text-align: center; padding: 40px 16px; font-size: 13px; line-height: 1.6; }

/* section header — utility type role */
.sec {
  display: flex; align-items: baseline; gap: 7px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 650; margin: 20px 0 8px;
}
.sec:first-of-type { margin-top: 0; }
.sec .count {
  font-size: 11px; letter-spacing: 0; color: var(--muted);
  background: var(--sunken); border: 1px solid var(--line);
  border-radius: 20px; padding: 0 6px; font-variant-numeric: tabular-nums;
}
.sec hr { flex: 1; height: 1px; border: 0; background: var(--line); }

/* input well — pinned above its list so a long list never pushes it away */
.well {
  display: grid; gap: 6px; padding: 10px;
  background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r);
  margin-bottom: 10px;
}
.well .cols { display: flex; gap: 6px; }
.well .cols > * { flex: 1; min-width: 0; }
.well textarea { resize: vertical; min-height: 34px; line-height: 1.4; }
.well .btn { justify-self: stretch; }

.stack { display: flex; flex-direction: column; gap: 8px; }

/* ---------------------------------------------------------------- cards */
.card {
  position: relative; border: 1px solid var(--line); border-radius: var(--r);
  padding: 9px 11px 9px 14px; background: #fff;
}
/* severity stripe: priority readable before any text is */
.card.sev::before {
  content: ""; position: absolute; left: 0; top: -1px; bottom: -1px; width: 3px;
  border-radius: var(--r) 0 0 var(--r); background: var(--p3);
}
.card.sev.p1::before { background: var(--p1); }
.card.sev.p2::before { background: var(--p2); }
.card.sev.p3::before { background: var(--p3); }
.card.sev.p4::before { background: var(--p4); }

.card-top { display: flex; align-items: baseline; gap: 8px; }
.card-top h4 { margin: 0; font-size: 13.5px; font-weight: 600; flex: 1; line-height: 1.35; }
.card-top time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.card.quiet { background: var(--sunken); }
.card.quiet .card-top h4 { color: var(--ink-2); font-weight: 550; }

.card-meta { margin-top: 4px; font-size: 12px; color: var(--muted);
             display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.notes { margin: 6px 0 0; font-size: 12.5px; color: var(--ink-2); white-space: pre-wrap; }
.card-acts { display: flex; gap: 4px; justify-content: flex-end; margin-top: 7px; }
/* a form opened inside a card: the editor for a finished item, the triage of a
   report. It has to read as a layer above the card, not as part of it. */
.card .well { margin: 8px 0 0; }
.card.quiet .well { background: #fff; }
.ghost {
  background: none; border: 0; padding: 3px 7px; border-radius: 6px;
  font-size: 12px; color: var(--muted); cursor: pointer;
}
.ghost:hover { background: var(--sunken); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.ghost.ok:hover  { color: var(--done); }
.ghost.del:hover { color: var(--p1); }

/* chips — state encoded in form, not only in words */
.chip {
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 4px; white-space: nowrap;
  color: #fff; background: var(--p3);
}
.chip.p1 { background: var(--p1); } .chip.p2 { background: var(--p2); }
.chip.p3 { background: var(--p3); } .chip.p4 { background: var(--p4); }
.chip.ok { background: #e6f4ea; color: var(--done); }
.chip.log { background: var(--sunken); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.overdue { color: var(--p1); font-weight: 600; }

/* ---------------------------------------------------------------- list tab */
.row-card {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 9px 11px 9px 13px; background: #fff; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--r); position: relative;
}
.row-card::before {
  content: ""; position: absolute; left: 0; top: -1px; bottom: -1px; width: 3px;
  border-radius: var(--r) 0 0 var(--r); background: var(--p3);
}
.row-card.p1::before { background: var(--p1); } .row-card.p2::before { background: var(--p2); }
.row-card.p3::before { background: var(--p3); } .row-card.p4::before { background: var(--p4); }
.row-card.log::before { background: var(--line-2); }
.row-card:hover { border-color: var(--line-2); background: var(--sunken); }
.row-main { flex: 1; min-width: 0; }
.row-title { display: block; font-size: 13.5px; font-weight: 600; line-height: 1.35; }
.row-card.log .row-title, .row-card.done .row-title { font-weight: 550; color: var(--ink-2); }
.row-meta {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  margin-top: 3px; font-size: 12px; color: var(--muted);
}
.row-meta .where { font-weight: 550; color: var(--ink-2); }

/* ---------------------------------------------------------------- pin head */
.pin-head { border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 14px; }
.pin-head input[type=text] { width: 100%; font-size: 15px; font-weight: 600; padding: 7px 10px; }
.pin-head .card-acts { margin-top: 7px; }

/* ================================================================ accounts,
   administration and the public reporting page. Same utilitarian light theme:
   every colour explicit, severity colour never used as an accent. */

input[type=password], input[type=number], input[type=file], input[type=email] {
  padding: 6px 9px; border: 1px solid var(--line-2); border-radius: 7px;
  background: #fff; outline-offset: -1px;
}
.btn.wide { width: 100%; }
.hint-text { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.by { font-size: 11.5px; color: var(--muted); margin-right: auto; }
.card-acts .by { align-self: center; }
.err {
  font-size: 12.5px; color: var(--p1); background: #fdecea;
  border: 1px solid #f5c6c2; border-radius: var(--r); padding: 7px 10px;
}

/* ---------------------------------------------------------------- who bar */
.who { display: flex; align-items: center; gap: 8px; }
.who .user { font-size: 12px; color: var(--muted); white-space: nowrap; }
.tabs .badge {
  display: inline-block; min-width: 17px; padding: 0 5px; margin-left: 5px;
  background: var(--p1); color: #fff; border-radius: 20px;
  font-size: 10.5px; font-weight: 700; vertical-align: 1px;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- login */
body.centred { display: grid; place-items: center; background: var(--bg); overflow: auto; }
.login {
  display: grid; gap: 10px; width: min(340px, 92vw); padding: 22px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 6px 30px rgba(19,32,47,.09);
}
.login.wide-form { width: min(420px, 94vw); }
.login h1 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.login .sub { margin: -4px 0 6px; font-size: 12.5px; color: var(--muted); }
.login label { display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); font-weight: 550; }
.centred-box { max-width: 460px; margin: 18vh auto; padding: 0 20px; text-align: center; }
.centred-box h1 { font-size: 19px; }
.centred-box p { color: var(--muted); }

/* ------------------------------------------------------------ admin sheet */
.overlay {
  position: fixed; inset: 0; background: rgba(19,32,47,.42);
  display: grid; place-items: center; z-index: 1200; padding: 18px;
}
.sheet {
  background: var(--panel); border-radius: 12px; border: 1px solid var(--line);
  width: min(1080px, 100%); height: min(88vh, 100%);
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 12px 50px rgba(19,32,47,.28);
}
.sheet-head {
  display: flex; align-items: center; gap: 14px; padding: 10px 14px;
  border-bottom: 1px solid var(--line); flex: none;
}
.sheet-head h2 { margin: 0; font-size: 14.5px; font-weight: 650; white-space: nowrap; }
.sheet-head .tabs { flex: 1; border: 0; }
.sheet-head .tabs button { flex: none; padding: 8px 12px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 16px; }

.admin-site {
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px; margin-bottom: 12px; background: #fff;
}
.site-head, .floor-row, .user-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.site-head { margin-bottom: 8px; }
.site-head input[name=name] { flex: 1 1 200px; font-weight: 600; }
.site-head .addr { flex: 2 1 240px; }
.floors { display: grid; gap: 6px; margin: 10px 0; }
.floors .empty { padding: 14px; }
.floor-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px;
  background: var(--sunken); border: 1px solid var(--line);
  border-radius: var(--r); padding: 7px 9px;
}
.floor-fields, .floor-acts { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.floor-fields input[name=name] { flex: 1 1 180px; }
.floor-thumb {
  width: 64px; height: 48px; object-fit: cover; object-position: center top;
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
}
.floor-thumb.lg { width: 128px; height: 96px; object-fit: contain; }
@media (max-width: 720px) {
  .floor-row { grid-template-columns: auto minmax(0, 1fr); }
  .floor-acts { grid-column: 1 / -1; }
}
/* People are edited where they are read: the username is a field, not a label. */
.user-row input[name=username] { flex: 1 1 130px; font-weight: 600; }
.user-row input[name=name]     { flex: 1 1 150px; }
.user-row input[name=email]    { flex: 1 1 150px; }

/* An address and the map that finds it are one control, not two fields that
   happen to sit together: typing the one is how you get the other. */
.addr {
  display: flex; align-items: stretch;
  background: #fff; border: 1px solid var(--line-2); border-radius: 7px;
}
.addr input[type=text] {
  flex: 1; min-width: 0; border: 0; border-radius: 6px 0 0 6px; background: none;
}
.addr .ghost {
  border-radius: 0 6px 6px 0; border-left: 1px solid var(--line);
  padding: 4px 9px; font-size: 12.5px; white-space: nowrap;
}

.linkbox {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  background: var(--accent-soft); border: 1px solid #cfe0fd;
  border-radius: var(--r); padding: 7px 9px;
}
.linkbox input { flex: 1 1 260px; font-size: 12px; background: #fff; }

/* ------------------------------------------------------------- plan wizard */
.wizard { border: 1px solid var(--accent); border-radius: var(--r); padding: 12px; }
.wizard-head { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; }
.wizard-head .sec { margin: 0 0 8px; }
.wizard-grid { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }

/* step one: the picture itself */
.swap-note {
  display: flex; gap: 12px; align-items: center; margin-bottom: 10px;
  background: var(--accent-soft); border: 1px solid #cfe0fd;
  border-radius: var(--r); padding: 10px;
}
.swap-note p { margin: 3px 0 0; }
.wizard label.dropzone {
  display: flex; gap: 14px; align-items: center; justify-content: center; text-align: center;
  min-height: 116px; padding: 18px; cursor: pointer; font-weight: 400;
  background: var(--sunken); border: 2px dashed var(--line-2); border-radius: var(--r);
}
.wizard label.dropzone:hover { border-color: var(--accent); }
.wizard label.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.wizard label.dropzone.filled {
  justify-content: flex-start; text-align: left; padding: 12px; min-height: 0;
}
.dz-text { display: grid; gap: 2px; }
.dz-text b { font-size: 13.5px; color: var(--ink); }
.dz-text .hint-text { font-weight: 400; }
.dz-thumb {
  width: 104px; height: 78px; object-fit: contain;
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
}
.progress {
  height: 6px; margin-top: 10px; overflow: hidden;
  background: var(--line); border-radius: 4px;
}
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .12s linear; }
.form-error { margin: 8px 0 0; font-size: 12.5px; color: var(--p1); }

/* step two: preview, with the same picture shown three ways */
.preview-col { display: grid; gap: 8px; flex: 1 1 380px; min-width: 280px; align-content: start; }
.seg {
  display: inline-flex; justify-self: start; overflow: hidden;
  background: #fff; border: 1px solid var(--line-2); border-radius: 7px;
}
.seg button {
  padding: 5px 11px; font-size: 12.5px; cursor: pointer;
  background: #fff; border: 0; border-right: 1px solid var(--line);
}
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--sunken); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.preview-wrap {
  position: relative; flex: none; min-width: 0; overflow: hidden;
  background: #e3e9f1; border: 1px solid var(--line); border-radius: var(--r);
  padding: 8px; touch-action: none; cursor: crosshair; line-height: 0;
}
/* Without this the browser starts its own picture drag and the crop gesture is
   cancelled after the first millimetre — the same guard as on the map. */
#prevImg {
  max-width: 100%; display: block; background: #fff;
  user-select: none; -webkit-user-drag: none;
}
.croprect {
  position: absolute; border: 2px solid var(--accent);
  box-shadow: 0 0 0 9999px rgba(19,32,47,.42); pointer-events: none;
}
.preview-busy {
  position: absolute; top: 12px; right: 12px; background: rgba(19,32,47,.9);
  color: #fff; font-size: 11px; padding: 3px 9px; border-radius: 20px; line-height: 1.5;
}
.wizard .well { flex: 1 1 260px; margin: 0; }
.wizard label { display: grid; gap: 3px; font-size: 12px; color: var(--ink-2); font-weight: 550; }
.wizard label.check { display: flex; align-items: center; gap: 7px; font-weight: 500; }
.wizard input[type=range] { width: 100%; }
.wizard .num { color: var(--muted); font-weight: 400; }

/* --------------------------------------------------------------- reports */
.pin.report {
  background: #fff; border: 2px dashed var(--p2);
  border-radius: 50% 50% 50% 3px;
}
.pin.report span { color: var(--p2); }
.card.report { border-left: 3px solid var(--p2); }
.flash { animation: flash 1.4s ease-out 1; }
@keyframes flash { from { background: var(--accent-soft); } to { background: #fff; } }
@media (prefers-reduced-motion: reduce) { .flash { animation: none; } }

/* ---------------------------------------------------- public report page */
body.public aside { width: 420px; }
body.public .panel { padding: 16px; }
.place {
  font-size: 12px; color: var(--ink-2); background: #fff;
  border: 1px dashed var(--line-2); border-radius: var(--r); padding: 7px 9px;
}
.thanks { text-align: center; padding: 30px 10px; display: grid; gap: 10px; justify-items: center; }
.thanks h2 { margin: 0; font-size: 17px; }
.thanks p { margin: 0; color: var(--muted); font-size: 13px; }

/* ------------------------------------------------------------- the manual */
/* A document rather than a tool screen: it scrolls under a fixed header, keeps
   a readable measure, and borrows the app's own colours so the two read as one
   product rather than as a manual bolted onto it. */
body.doc main { display: block; overflow-y: auto; }
.login .foot { margin: 2px 0 0; text-align: center; }
.login .foot a { color: var(--muted); text-decoration: none; }
.login .foot a:hover { color: var(--accent); text-decoration: underline; }

.doc-body {
  max-width: 800px; margin: 0 auto; padding: 24px 30px 80px;
  background: var(--panel); border-left: 1px solid var(--line);
  border-right: 1px solid var(--line); min-height: 100%;
  color: var(--ink-2); line-height: 1.65;
}
.doc-body h2 {
  display: flex; align-items: center; gap: 9px; margin: 32px 0 10px; padding-top: 18px;
  font-size: 17px; font-weight: 650; letter-spacing: -.01em; color: var(--ink);
  border-top: 1px solid var(--line);
}
.doc-body h3 { margin: 20px 0 6px; font-size: 14px; font-weight: 650; color: var(--ink); }
.doc-body p { margin: 0 0 10px; }
.doc-body ul, .doc-body ol { margin: 0 0 12px; padding-left: 20px; }
.doc-body li { margin-bottom: 5px; }
.doc-body b { color: var(--ink); font-weight: 600; }
.doc-body a { color: var(--accent); }

.toc {
  background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 15px; margin-bottom: 6px;
}
.toc b {
  display: block; margin-bottom: 5px; font-size: 11px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
}
.toc ol { margin: 0; padding-left: 20px; }
.toc li { margin: 0; }

.doc-body table { width: 100%; border-collapse: collapse; margin: 0 0 14px; font-size: 13px; }
.doc-body th, .doc-body td {
  padding: 7px 10px; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--line);
}
.doc-body th {
  font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); border-bottom-color: var(--line-2);
}
.doc-body td:first-child { width: 34%; color: var(--ink); }

pre.tree {
  margin: 0 0 14px; padding: 12px 14px; overflow-x: auto;
  background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r);
  font: 12.5px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-2);
}
kbd {
  padding: 2px 5px; white-space: nowrap; color: var(--ink);
  font: 600 11.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #fff; border: 1px solid var(--line-2); border-bottom-width: 2px;
  border-radius: 4px;
}
code {
  padding: 1px 4px; font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--sunken); border: 1px solid var(--line); border-radius: 4px;
}
.note {
  margin: 0 0 14px; padding: 9px 12px; font-size: 13px;
  background: var(--accent-soft); border: 1px solid #cfe0fd; border-radius: var(--r);
}
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; list-style: none; padding: 0; }
.legend li { display: flex; align-items: center; gap: 7px; margin: 0; }
/* The same teardrop as on the plan, so the key is recognisably the pin. */
.dot {
  display: inline-block; width: 13px; height: 13px;
  border-radius: 50% 50% 50% 3px; transform: rotate(-45deg); background: var(--p3);
}
.dot.p1 { background: var(--p1); } .dot.p2 { background: var(--p2); }
.dot.p4 { background: var(--p4); } .dot.ok { background: var(--done); }

/* --------------------------------------------------------------- narrow */
@media (max-width: 820px) {
  header { flex-wrap: wrap; }
  header input[type=search] { width: 140px; }
  main { flex-direction: column; }
  aside, body.public aside { width: auto; border-left: 0; border-top: 1px solid var(--line); }
  #stage { min-height: 46vh; }
  aside { max-height: 54vh; }
}
