:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #646b73;
  --border: #dcd9d2;
  --accent: #2f5d8a;
  --accent-text: #ffffff;
  --danger: #a33a2c;
  --ok-bg: #e6f2e4;
  --err-bg: #f8e3df;
  --row-hover: #f0eee9;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  color: var(--text);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Top bar */
.topbar { background: #23384d; color: #fff; }
.topbar .inner { max-width: 1200px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 1.25rem; min-height: 52px; flex-wrap: wrap; }
.topbar .brand { font-weight: 600; letter-spacing: .02em; }
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.topbar nav a { color: #d7e2ec; text-decoration: none; padding: .4rem .7rem; border-radius: 6px; }
.topbar nav a.active, .topbar nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.topbar form { margin: 0; }
.topbar .user { color: #b9c7d4; font-size: .9rem; }
.topbar button.link { background: none; border: 0; color: #d7e2ec; cursor: pointer; font: inherit; text-decoration: underline; padding: 0 0 0 .5rem; }

main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 48px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.cols { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }

/* Buttons and forms */
.btn, button.btn { display: inline-block; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: .45rem .85rem; font: inherit; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: #b9b5ac; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--danger); }
.btn.small { padding: .2rem .55rem; font-size: .88rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

input, select, textarea { font: inherit; padding: .4rem .5rem; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text); width: 100%; }
input[type=checkbox] { width: auto; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
.field { margin-bottom: .75rem; }
.field.check { display: flex; gap: .5rem; align-items: center; }
.field.check label { margin: 0; color: var(--text); font-size: 1rem; }
.field .help { font-size: .8rem; color: var(--muted); margin-top: .2rem; }
.errorlist { color: var(--danger); margin: .2rem 0 0; padding: 0; list-style: none; font-size: .85rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 1rem; }
.field.lookup { max-width: 640px; }
#address-lookup gmp-place-autocomplete { width: 100%; }
input.filled { background: #eef6e6; transition: background .3s; }
p.help { font-size: .82rem; margin: 0 0 .75rem; }
fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 0 0 1rem; padding: 12px 16px 4px; background: var(--surface); }
legend { font-weight: 600; padding: 0 .35rem; }

.search { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: .5rem; align-items: end; margin-bottom: 1rem; }
@media (max-width: 700px) { .search { grid-template-columns: 1fr 1fr; } }

/* Tables */
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { padding: .45rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #faf9f6; position: sticky; top: 0; }
tbody tr:hover { background: var(--row-hover); }
tr.voided td { color: var(--muted); text-decoration: line-through; }
tr.selected td { background: #e4ecf4; }
tfoot td { font-weight: 600; border-top: 2px solid var(--border); }
.table-wrap { border: 1px solid var(--border); border-radius: 8px; overflow: auto; max-height: 70vh; }
.table-wrap table { border: 0; }

/* Clickable text that looks like plain text (report names). */
a.quiet-link { color: inherit; text-decoration: none; }

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: .6rem .8rem; border-radius: 6px; margin-bottom: .4rem; background: var(--ok-bg); }
.messages li.error { background: var(--err-bg); }
.badge { display: inline-block; font-size: .78rem; padding: .05rem .45rem; border-radius: 99px; background: #ece9e2; color: var(--muted); }

dl.info { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
dl.info dt { color: var(--muted); }
dl.info dd { margin: 0; }

.envelope-current { margin: 0 0 .6rem; }
.envelope-current strong { font-size: 1.2rem; }
.envelope-row { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }
.envelope-row .field { width: 160px; margin-bottom: 0; }
.envelope-status { min-height: 1.4rem; margin: .5rem 0 .25rem; font-weight: 500; }
.envelope-status.good { color: #3d7a33; }
.envelope-status.warn { color: #9a6200; }
.envelope-status.bad { color: var(--danger); }
button:disabled { opacity: .5; cursor: not-allowed; }
.history { list-style: none; padding: 0; margin: 0; font-size: .9rem; }
.history li { padding: .3rem 0; border-bottom: 1px solid var(--border); }
.history li:last-child { border-bottom: 0; }

.back-card { display: block; margin-top: 12px; text-align: center; font-size: 1.1rem; font-weight: 600;
  background: var(--accent); border-color: var(--accent); color: var(--accent-text); text-decoration: none; }
.back-card:hover { background: #264d73; }

.owner-card { margin-top: 12px; border-left: 4px solid #4c8a3f; background: #f3f8ef; line-height: 1.45; }
.owner-card.not-found { border-left-color: var(--danger); background: var(--err-bg); }
.owner-card .owner-number { font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.owner-card .owner-contact { margin-top: .45rem; padding-top: .45rem; border-top: 1px solid rgba(0,0,0,.08); }
.owner-card .owner-name { font-size: 1.25rem; font-weight: 600; margin: .1rem 0 .3rem; }

/* Public registration page */
.public { max-width: 760px; margin: 0 auto; }
.public-parish { color: var(--accent); font-weight: 600; margin: 0 0 .25rem; letter-spacing: .02em; }
.public h1 { font-size: 1.8rem; margin-bottom: .75rem; }
.public > p { line-height: 1.55; }
.public-footer { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem; }
.privacy { margin: .5rem 0 1rem; }
.big-button { font-size: 1.05rem; padding: .65rem 1.4rem; }
.trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.nav-count { display: inline-block; min-width: 1.3rem; padding: 0 .35rem; margin-left: .3rem; border-radius: 99px;
  background: #e0a526; color: #1f2328; font-size: .78rem; font-weight: 700; text-align: center; }
.changes { width: auto; margin: .4rem 0 .2rem; background: transparent; }
.changes td { padding: .15rem .8rem .15rem 0; border: 0; }
.notice { padding: .7rem .9rem; border-radius: 8px; background: #fff7e0; border: 1px solid #ecd28a; margin-bottom: 1rem; }

.login { max-width: 360px; margin: 10vh auto; }
.big { font-size: 1.4rem; }

@media print {
  .topbar, .no-print, .messages { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .table-wrap { max-height: none; overflow: visible; border: 0; }
  th { position: static; }
}
