:root {
  --navy: #14284b; --navy-deep: #0e1d38; --green: #2c9a66; --green-dark: #1f7a4f;
  --paper: #f4f6f8; --card: #ffffff; --ink: #18222f; --muted: #5b6676; --line: #dce2e9; --line-soft: #ebeff3;
  --amber: #b7791f; --red: #b23a32; --blue: #2f6db5; --orange: #d0772b;
  --amber-bg: #fdf3dc; --red-bg: #fbe9e7; --green-bg: #e4f4ec; --blue-bg: #e6eff9;
  --radius: 6px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--paper); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; line-height: 1.25; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 10px; font-weight: 650; }
h3 { font-size: 14px; margin: 0 0 6px; font-weight: 650; }
p { margin: 0 0 10px; }
small, .small { font-size: 12.5px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* layout */
.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--navy-deep); color: #c9d3e3; padding: 18px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { padding: 0 20px 16px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 10px; }
.brand b { display: block; font: 700 19px/1.1 Montserrat, system-ui, sans-serif; color: #fff; letter-spacing: -0.02em; text-transform: lowercase; }
.brand b i { font-style: normal; color: #58c692; }
.brand span { font-size: 12px; color: #8c9ab3; }
.brand img { display: block; max-width: 100%; height: auto; margin-bottom: 8px; }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: 8px 20px; color: #c9d3e3; border-left: 3px solid transparent; }
.nav a:hover { background: rgba(255,255,255,.05); text-decoration: none; color: #fff; }
.nav a.on { color: #fff; border-left-color: #58c692; background: rgba(255,255,255,.07); }
.nav .count { background: #e9b949; color: #2b2100; border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 650; }
.nav hr { border: 0; border-top: 1px solid rgba(255,255,255,.08); margin: 10px 0; }
.who { padding: 12px 20px 0; font-size: 12.5px; color: #8c9ab3; }
.who form { margin-top: 6px; }
.linkbtn { background: none; border: 0; padding: 0; color: #c9d3e3; cursor: pointer; font: inherit; text-decoration: underline; }
.main { padding: 24px 28px 60px; max-width: 1320px; width: 100%; }
.head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: flex-end; margin-bottom: 18px; }
.head p { margin: 4px 0 0; color: var(--muted); max-width: 78ch; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-side { grid-template-columns: 200px minmax(0, 1fr); }
.main, .grid > * { min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { padding: 14px 18px 0; }
.card + .card, .grid + .card, .card + .grid, .grid + .grid { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.demo-bar { background: var(--amber-bg); color: #6b4a0b; border: 1px solid #ecd49a; border-radius: var(--radius); padding: 8px 12px; margin-bottom: 16px; }

/* tables */
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { font-size: 12.5px; font-weight: 600; color: var(--muted); background: #fafbfc; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
td.nowrap { white-space: nowrap; }
tbody tr:hover td { background: #fbfcfd; }
.ledger td:first-child { color: var(--ink); }
.ledger td:last-child { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; width: 30%; }
.ledger tr.sub td:first-child { padding-left: 28px; color: var(--muted); }
.ledger tr.sub td:last-child { font-weight: 500; }
.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.unknown { color: #8a94a3; letter-spacing: .02em; font-size: 12.5px; }

/* pills */
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; background: #eef1f5; color: #3c4758; }
.t-HOT { background: #fbe1dc; color: #8c2219; } .t-HIGH { background: var(--amber-bg); color: #7a5108; }
.t-MEDIUM { background: var(--blue-bg); color: #1f4f8c; } .t-LOW { background: #eef1f5; color: #586273; }
.st-new { background: var(--blue-bg); color: #1f4f8c; } .st-wait { background: var(--amber-bg); color: #7a5108; }
.st-sent { background: var(--green-bg); color: #17603d; } .st-warm { background: #f9e4d1; color: #8a4710; }
.st-won { background: #17603d; color: #fff; } .st-lost { background: #e4e7ec; color: #586273; }
.v-valid { background: var(--green-bg); color: #17603d; } .v-invalid { background: var(--red-bg); color: #8c2219; }
.v-unknown, .v-risky, .v-catch_all { background: var(--amber-bg); color: #7a5108; }
.score { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; font-weight: 650; }
.bar { height: 8px; background: #e6eaef; border-radius: 4px; overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: var(--green); }
.bar.partial > i { background: #8fcfae; }

/* forms */
label { display: block; font-weight: 600; margin-bottom: 4px; }
label .hint, .hint { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=time], input[type=week], input[type=search], select, textarea {
  width: 100%; padding: 7px 9px; border: 1px solid #c5ced9; border-radius: 5px; font: inherit; color: inherit; background: #fff; }
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
textarea.body { min-height: 420px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.field { margin-bottom: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.row > * { flex: 1 1 140px; }
.row > .fit { flex: 0 0 auto; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.checks label, label.check { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; margin: 0; }
.btn { display: inline-block; padding: 7px 13px; border: 1px solid #c5ced9; border-radius: 5px; background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f3f5f8; text-decoration: none; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-dark); }
.btn.danger { color: var(--red); border-color: #e2b6b2; }
.btn.danger:hover { background: var(--red-bg); }
.btn.sm { padding: 3px 9px; font-size: 12.5px; }
form.inline { display: inline; }
.filters { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; }
.flash { border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; border: 1px solid; }
.flash.ok { background: var(--green-bg); border-color: #b5dfc8; color: #17603d; }
.flash.error { background: var(--red-bg); border-color: #efc2bd; color: #8c2219; }
.flash.warn { background: var(--amber-bg); border-color: #ecd49a; color: #6b4a0b; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--green); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; color: var(--muted); border-top: 1px solid var(--line-soft); }
.empty { padding: 28px 18px; color: var(--muted); text-align: center; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
ul.plain li:last-child { border-bottom: 0; }
ul.warns { margin: 0; padding-left: 18px; color: #6b4a0b; }
.warnbox { background: var(--amber-bg); border: 1px solid #ecd49a; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; }
.snippet { background: #f7f9fb; border-left: 3px solid var(--line); padding: 6px 10px; font-size: 12.5px; color: #3c4758; margin-top: 4px; overflow-wrap: anywhere; }
pre.mail { white-space: pre-wrap; overflow-wrap: anywhere; font: 14px/1.55 system-ui, -apple-system, "Segoe UI", Arial, sans-serif; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin: 0; max-width: 78ch; }
pre.report { white-space: pre-wrap; font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; margin: 0; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.timeline li:last-child { border: 0; }
.timeline time { color: var(--muted); font-size: 12.5px; }

/* pipeline */
.stages { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.stage { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.stage h3 { display: flex; justify-content: space-between; margin-bottom: 6px; }
.stage ul { list-style: none; padding: 0; margin: 0; font-size: 12.5px; }
.stage li { padding: 3px 0; display: flex; justify-content: space-between; gap: 8px; }
.stage li a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flowline { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 12.5px; color: var(--muted); }

/* maps */
#map, #covmap { height: 620px; border: 1px solid var(--line); border-radius: var(--radius); background: #e9eef3; z-index: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 0; font-size: 12.5px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0,0,0,.25); }
.dot.contacted { background: #2c9a66; } .dot.new { background: #2f6db5; } .dot.awaiting { background: #e9b949; }
.dot.followup { background: #d0772b; } .dot.nocontact { background: #b23a32; } .dot.star { background: #fff; border: 2px solid #18222f; }
.sq { width: 12px; height: 12px; display: inline-block; border: 1px solid rgba(0,0,0,.25); }
.sq.scanned { background: #2c9a66; } .sq.partial { background: #e9b949; } .sq.not_scanned { background: #c9d1db; }
.leaflet-popup-content { font: 13px/1.45 system-ui, sans-serif; margin: 12px 14px; }
.leaflet-popup-content dl { display: grid; grid-template-columns: 78px 1fr; gap: 2px 8px; margin: 6px 0; }
.leaflet-popup-content dt { color: var(--muted); } .leaflet-popup-content dd { margin: 0; overflow-wrap: anywhere; }

/* login & public */
.center { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--navy-deep); }
.center .card { width: 100%; max-width: 380px; padding: 26px; }
.center .brand { padding: 0 0 14px; border-color: var(--line); }
.center .brand b { color: var(--navy); } .center .brand b i { color: var(--green); }
.center .brand span { color: var(--muted); }

@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; padding: 10px 0 6px; }
  .brand { padding-bottom: 8px; margin-bottom: 4px; }
  .nav { display: flex; overflow-x: auto; }
  .nav a { border-left: 0; border-bottom: 3px solid transparent; padding: 8px 12px; white-space: nowrap; gap: 6px; }
  .nav a.on { border-bottom-color: #58c692; }
  .nav hr { display: none; }
  .who { display: flex; gap: 12px; padding-top: 6px; }
  .main { padding: 16px; }
  .g2, .g3, .g-main, .g-side { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: 110px minmax(0, 1fr); }
  .timeline li { grid-template-columns: 1fr; gap: 0; }
  #map, #covmap { height: 460px; }
}
@media print { .side, .actions, .filters { display: none; } .shell { display: block; } }

/* long addresses and file names wrap instead of pushing the table wider than the page */
.brk{overflow-wrap:anywhere;word-break:break-word}
.w-prop{min-width:180px}
.w-contact{min-width:130px}
.w-subject{min-width:200px}
.w-email{min-width:215px}
.w-att{min-width:150px}
