:root {
  color-scheme: light;
  --bg: #FBFAF8;
  --surface: #FFFFFF;
  --surface-2: #F4F3F0;
  --border: #DCD9D3;
  --border-strong: #B8B4AC;
  --text: #14181B;
  --muted: #5A6368;
  --brand: #0E5B57;
  --brand-strong: #0A4744;
  --brand-soft: #E3F0EE;
  --amber: #9A5B00;
  --amber-soft: #FBF0DF;
  --green: #0B6B45;
  --green-soft: #E7F2EC;
  --red: #A4262C;
  --red-soft: #F9E9EA;
  --blue: #1D4ED8;
  --blue-soft: #E8EDFB;
  --focus: #0E5B57;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(16 24 32 / .06);
  --font: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-bottom: 64px;
}
h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}

.skip {
  position: absolute; left: -9999px; top: 0; background: var(--surface);
  padding: 10px 14px; border: 1px solid var(--border); z-index: 100; border-radius: 8px;
}
.skip:focus { left: 16px; top: 16px; }

/* ---------- top bar ---------- */
.topbar {
  max-width: 1240px; margin: 0 auto;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: var(--surface);
  display: grid; place-items: center; font-weight: 700; font-size: 16px;
}
.brand-text strong { display: block; font-size: 15px; line-height: 1.2; }
.brand-text small { display: block; font-size: 12px; color: var(--muted); }
.nav { display: flex; gap: 4px; margin-left: 12px; flex-wrap: wrap; }
.nav a {
  text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 500;
  padding: 7px 12px; border-radius: 8px;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.is-on { color: var(--text); background: var(--surface-2); }
.tenant-id {
  display: flex; flex-direction: column; gap: 1px; min-width: 0;
  padding-left: 14px; border-left: 1px solid var(--border);
}
.tenant-id strong {
  font-size: 14px; font-weight: 600; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px;
}
.tenant-id small {
  font-size: 11.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px;
}
.switch { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.switch select {
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px;
  padding: 6px 9px; font-size: 12.5px; max-width: 240px;
}

/* ---------- landing ---------- */
.landing { padding: 48px 0 30px; }
.landing-hero { max-width: 660px; }
.landing h1 { font-size: 44px; line-height: 1.08; letter-spacing: -.03em; margin: 8px 0 12px; text-wrap: balance; }
.landing .lede { color: var(--muted); font-size: 17px; max-width: 56ch; }
.tenant-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px; margin-top: 34px; max-width: 900px;
}
.tenant-card {
  display: block; text-decoration: none; color: inherit; position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px 22px 18px; box-shadow: var(--shadow);
}
.tenant-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--card-accent, var(--brand));
}
.tenant-card:hover { border-color: var(--border-strong); }
.tenant-card h2 { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.tenant-card .mp { font-size: 13px; color: var(--muted); margin-top: 3px; }
.tenant-card .count { font-size: 12px; color: var(--muted); margin-top: 14px; font-variant-numeric: tabular-nums; }
.landing-note { font-size: 12px; color: var(--muted); margin-top: 22px; }

/* ---------- flash + mp line ---------- */
.flash {
  display: flex; align-items: flex-start; gap: 10px; margin-top: 18px;
  background: var(--brand-soft); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 14px; font-size: 13.5px; line-height: 1.45;
}
.flash button {
  margin-left: auto; border: 0; background: transparent; color: var(--muted);
  font-size: 18px; line-height: 1; padding: 0 2px;
}
.mp-line { margin-top: 12px; font-size: 13px; color: var(--muted); }
.mp-line strong { color: var(--text); font-weight: 600; }

/* ---------- layout ---------- */
#app { max-width: 1240px; margin: 0 auto; outline: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 9px 15px; border-radius: 9px; font-size: 14px; font-weight: 600;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--border-strong); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn-danger { color: var(--red); border-color: #E7C9CB; background: var(--surface); }
.btn-danger:hover { background: var(--red-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 7px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.meta { font-size: 12.5px; color: var(--muted); }
.eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
}

/* ---------- hero ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px;
  align-items: end; padding: 34px 0 24px;
}
.hero h1 {
  font-size: 34px; line-height: 1.13; letter-spacing: -.028em; font-weight: 600;
  margin: 8px 0 10px; text-wrap: balance; max-width: 24ch;
}
.hero .lede { color: var(--muted); font-size: 16px; max-width: 52ch; }
.postcode-form { margin-top: 18px; max-width: 520px; }
.postcode-form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.postcode-row { display: flex; gap: 8px; }
.postcode-row input {
  flex: 1; min-width: 0; border: 1px solid var(--border-strong); border-radius: 9px;
  padding: 10px 12px; background: var(--surface); font-size: 16px;
}
.postcode-row input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.hero-figure {
  background: var(--brand-soft); border-radius: var(--radius); padding: 18px 20px;
  border: 1px solid #CFE4E1;
}
.hero-figure .big { font-size: 44px; font-weight: 600; letter-spacing: -.03em; line-height: 1; color: var(--brand); }
.hero-figure p { font-size: 13px; color: var(--text); margin-top: 6px; }
.hero-figure hr { border: 0; border-top: 1px solid #CFE4E1; margin: 14px 0; }
.hero-figure .split { display: flex; gap: 20px; }
.hero-figure .split strong { display: block; font-size: 20px; font-weight: 600; }
.hero-figure .split span { font-size: 11.5px; color: var(--muted); }

/* ---------- workspace ---------- */
.workspace {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(330px, .9fr);
  gap: 14px; height: 620px; margin-bottom: 28px;
}
.map-card { position: relative; overflow: hidden; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); }
#map { position: absolute; inset: 0; }
.map-fallback {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  padding: 24px; color: var(--muted); font-size: 14px;
}
.map-legend {
  position: absolute; left: 12px; bottom: 12px; z-index: 2;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; display: flex; gap: 14px; font-size: 11.5px; color: var(--muted);
  box-shadow: var(--shadow); flex-wrap: wrap;
}
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 999px; display: block; }
.legend-dot.official { background: var(--brand); }
.legend-dot.unverified { background: var(--amber); }
.maplibregl-ctrl-attrib { font-size: 10px; }
.pin {
  width: 20px; height: 20px; border-radius: 999px; padding: 0;
  border: 2px solid #fff; background: var(--brand);
  box-shadow: 0 1px 4px rgb(0 0 0 / .3);
}
.pin.unverified { background: var(--amber); border-style: dashed; }
.pin:hover { box-shadow: 0 0 0 4px rgb(14 91 87 / .18); }
.pin.unverified:hover { box-shadow: 0 0 0 4px rgb(154 91 0 / .22); }
.pin:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.list-card { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.list-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--border); }
.list-head h2 { font-size: 15px; font-weight: 600; display: flex; justify-content: space-between; align-items: baseline; }
.list-head h2 span { font-size: 12px; font-weight: 500; color: var(--muted); }
.filters { display: flex; gap: 8px; margin-top: 10px; }
.filters select {
  flex: 1; min-width: 0; border: 1px solid var(--border); background: var(--surface);
  border-radius: 8px; padding: 7px 9px; font-size: 12.5px;
}
.issue-list { overflow-y: auto; flex: 1; }
.issue-item {
  display: block; width: 100%; text-align: left; background: transparent; border: 0;
  border-bottom: 1px solid var(--border); padding: 13px 16px; color: inherit;
}
.issue-item:hover { background: var(--surface-2); }
.issue-item.is-selected { background: var(--brand-soft); }
.issue-item .row { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.issue-item strong { font-size: 14px; font-weight: 600; line-height: 1.35; display: block; }
.issue-item .meta { margin-top: 4px; display: block; }
.issue-item .ref { font-size: 11px; color: var(--muted); margin-bottom: 3px; display: block; }
.issue-item .support { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

/* ---------- pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  border: 1px solid transparent;
}
.pill::before { content: ""; width: 5px; height: 5px; border-radius: 999px; background: currentColor; flex: none; }
.st-unverified { background: var(--amber-soft); color: var(--amber); }
.st-received, .st-triage { background: var(--blue-soft); color: var(--blue); }
.st-open, .st-progress { background: var(--brand-soft); color: var(--brand); }
.st-waiting { background: var(--amber-soft); color: var(--amber); }
.st-resolved { background: var(--green-soft); color: var(--green); }
.st-closed { background: var(--surface-2); color: var(--muted); }
.st-held { background: var(--red-soft); color: var(--red); }

/* ---------- detail ---------- */
.back { display: inline-block; margin: 22px 0 12px; font-size: 13px; text-decoration: none; }
.back:hover { text-decoration: underline; }
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; padding-bottom: 40px; }
.detail-main, .detail-side .card { padding: 24px; }
.detail h1 { font-size: 30px; line-height: 1.18; letter-spacing: -.025em; margin: 8px 0 12px; text-wrap: balance; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.detail .meta { font-size: 13px; }
.detail .body { margin-top: 18px; font-size: 16.5px; line-height: 1.6; white-space: pre-wrap; }
.detail h2 { font-size: 15px; font-weight: 600; margin: 26px 0 12px; }
.notice {
  margin-top: 18px; padding: 13px 15px; border-radius: 10px;
  background: var(--amber-soft); border: 1px solid #EAD9BB; font-size: 13px; line-height: 1.5;
}
.detail-side { display: flex; flex-direction: column; gap: 14px; }
.detail-side h2 { font-size: 14px; font-weight: 600; margin: 0 0 6px; }
.detail-side .card { padding: 18px; }
.detail-side form { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.detail-side input {
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 9px 10px; font-size: 15px;
}

/* timeline */
.timeline { border-left: 2px solid var(--border); margin-left: 5px; padding-left: 18px; }
.timeline li { position: relative; padding-bottom: 16px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -24px; top: 5px; width: 10px; height: 10px;
  border-radius: 999px; background: var(--brand); border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--brand-soft);
}
.timeline .when { font-size: 11.5px; color: var(--muted); display: block; margin-bottom: 2px; }
.timeline .who { font-weight: 600; font-size: 12.5px; }
.timeline p { font-size: 14px; margin-top: 3px; line-height: 1.5; }

/* ---------- forms / report ---------- */
.page-head { padding: 34px 0 18px; }
.page-head h1 { font-size: 32px; letter-spacing: -.025em; line-height: 1.15; }
.page-head .lede { color: var(--muted); margin-top: 6px; max-width: 60ch; }
.report-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; padding-bottom: 40px; }
.form { padding: 24px; display: flex; flex-direction: column; gap: 6px; }
.form label { font-size: 13px; font-weight: 600; margin-top: 14px; }
.form label:first-child { margin-top: 0; }
.form input, .form select, .form textarea {
  border: 1px solid var(--border-strong); border-radius: 9px; padding: 10px 12px;
  background: var(--surface); font-size: 16px; width: 100%;
}
.form textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
.form input:focus, .form select:focus, .form textarea:focus {
  border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-soft);
}
.form .check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 14px; margin-top: 12px; line-height: 1.45; }
.form .check input { width: 17px; height: 17px; margin-top: 2px; flex: none; }
.form .submit-row { margin-top: 20px; display: flex; gap: 10px; align-items: center; }
.report-side .card-inner { padding: 18px; }
.report-side h2 { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.report-side ol { counter-reset: s; display: flex; flex-direction: column; gap: 10px; }
.report-side li { font-size: 13px; color: var(--muted); padding-left: 26px; position: relative; line-height: 1.45; }
.report-side li::before {
  counter-increment: s; content: counter(s);
  position: absolute; left: 0; top: 0; width: 18px; height: 18px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand); font-size: 10.5px; font-weight: 700;
  display: grid; place-items: center;
}
.result { margin: 0 0 30px; padding: 22px 24px; border-color: #BFDCD7; background: var(--brand-soft); }
.result h2 { font-size: 18px; margin-bottom: 8px; }
.result p { font-size: 14px; line-height: 1.55; }
.result .ref { font-family: var(--font); font-weight: 600; }
.result a { font-weight: 600; }

/* ---------- staff ---------- */
.staff-login { max-width: 420px; margin: 60px auto; padding: 28px; }
.staff-login h1 { font-size: 26px; margin-bottom: 6px; }
.staff-login .hint strong { white-space: nowrap; }
.staff-login .form { padding: 0; }
.staff-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding: 28px 0 16px; }
.staff-head h1 { font-size: 28px; letter-spacing: -.02em; }
.staff-head p { font-size: 13px; color: var(--muted); }
.staff-head .spacer { flex: 1; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 7px 13px; font-size: 12.5px; font-weight: 500; color: var(--muted);
}
.tab.is-on { background: var(--text); border-color: var(--text); color: var(--surface); }
.tab .n { font-weight: 700; margin-left: 4px; }
.queue { display: flex; flex-direction: column; gap: 8px; padding-bottom: 40px; }
.queue-item {
  display: flex; width: 100%; text-align: left; gap: 14px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border); border-radius: 11px;
  padding: 13px 15px; color: inherit;
}
.queue-item:hover { border-color: var(--border-strong); }
.queue-main { flex: 1; min-width: 0; }
.queue-main .ref { font-size: 11px; color: var(--muted); display: block; }
.queue-main strong { display: block; font-size: 14.5px; font-weight: 600; margin: 2px 0 3px; }
.queue-main .meta { font-size: 12px; }
.queue-main .held { display: block; margin-top: 5px; font-size: 12px; color: var(--red); }
.queue-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 14px; }

.staff-issue { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; padding-bottom: 40px; }
.staff-main { padding: 22px; }
.staff-main h1 { font-size: 26px; line-height: 1.2; letter-spacing: -.02em; margin: 6px 0 10px; }
.staff-main h2 { font-size: 14px; font-weight: 600; margin: 24px 0 10px; }
.staff-main .body { font-size: 15px; line-height: 1.55; white-space: pre-wrap; }
.reports { display: flex; flex-direction: column; gap: 8px; }
.reports li { border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; font-size: 13px; }
.reports .who { font-weight: 600; font-size: 12px; }
.reports .anon { color: var(--muted); font-style: italic; }
.notes { display: flex; flex-direction: column; gap: 8px; }
.notes li { background: var(--surface-2); border-radius: 9px; padding: 10px 12px; font-size: 13px; }
.notes .who { font-size: 11.5px; color: var(--muted); display: block; margin-bottom: 2px; }
.staff-side { display: flex; flex-direction: column; gap: 12px; }
.staff-side .card { padding: 16px; }
.staff-side h2 { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.staff-side label { display: block; font-size: 12px; font-weight: 600; margin: 10px 0 4px; color: var(--muted); }
.staff-side input, .staff-side select, .staff-side textarea {
  width: 100%; border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 8px 10px; font-size: 14px; background: var(--surface);
}
.staff-side textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
.staff-side .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.staff-side .row .btn { flex: 1; }
.staff-side .stack { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.danger-card { border-color: #E7C9CB; }
.danger-card h2 { color: var(--red); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--text); color: var(--surface); padding: 11px 16px; border-radius: 9px;
  font-size: 13.5px; z-index: 50; box-shadow: 0 8px 24px rgb(0 0 0 / .18); max-width: 90vw;
}
.toast.err { background: var(--red); }

/* ---------- responsive ---------- */
@media (max-width: 1040px) {
  .workspace { grid-template-columns: 1fr; height: auto; }
  .map-card { height: 420px; }
  .list-card { max-height: 520px; }
  .detail, .report-grid, .staff-issue { grid-template-columns: 1fr; }
  .detail-side { display: grid; grid-template-columns: 1fr 1fr; }
  .hero { grid-template-columns: 1fr; align-items: start; }
  .hero-figure { max-width: 420px; }
}
@media (max-width: 680px) {
  .topbar { gap: 10px; }
  .tenant-id { padding-left: 10px; flex: 1; min-width: 0; }
  .tenant-id strong, .tenant-id small { max-width: 100%; }
  .switch { order: 2; }
  .switch span { display: none; }
  .switch select { max-width: 150px; }
  .nav { order: 3; width: 100%; margin-left: 0; }
  .nav a { flex: 1; text-align: center; }
  .landing h1 { font-size: 32px; }
  .hero h1 { font-size: 30px; }
  .hero { padding-top: 24px; }
  .map-card { height: 340px; }
  .detail-side { grid-template-columns: 1fr; }
  .detail-main, .form { padding: 18px; }
  .result { padding: 18px; }
  .staff-head { gap: 8px; }
}
