:root {
  --bg: #f4f5f7; --panel: #ffffff; --text: #1f2328; --muted: #656d76; --line: #d8dee4;
  --accent: #0c8282; --accent-text: #ffffff; --warn-bg: #fff4d6; --warn: #8a5a00;
  --bad-bg: #fde8e8; --bad: #b42318; --good-bg: #e3f6ec; --good: #1a7f4b; --code-bg: #fbfbfc;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181c; --panel: #1e2227; --text: #e6e8eb; --muted: #9aa3ad; --line: #353b43;
    --accent: #2bb3b3; --accent-text: #0b1214; --warn-bg: #3b2f12; --warn: #f2c35b;
    --bad-bg: #3d1a1a; --bad: #ff8a80; --good-bg: #163325; --good: #6fd19c; --code-bg: #181b20;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--bad); }
button.small { padding: 2px 8px; font-size: 12px; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 6px; font-size: 14px; color: var(--text); }
.muted { color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.spacer { flex: 1; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; text-decoration: none; color: var(--text); white-space: nowrap; }
.brand span { color: var(--accent); }
.top-status { flex: 1; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
main { padding: 16px; max-width: 1500px; margin: 0 auto; }
h1 { font-size: 20px; margin: 0 0 4px; } h2 { font-size: 16px; margin: 0 0 8px; } h3 { font-size: 14px; margin: 0 0 6px; }

.banner { padding: 8px 12px; border-radius: 6px; margin: 0 0 12px; }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.banner.warn { background: var(--warn-bg); color: var(--warn); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.card.clickable { cursor: pointer; } .card.clickable:hover { border-color: var(--accent); }
.card.new { align-items: center; justify-content: center; border-style: dashed; color: var(--muted); min-height: 160px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
.badge.good { background: var(--good-bg); color: var(--good); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 13px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 12px 0 16px; overflow-x: auto; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .split { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.pill { padding: 4px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); }
.pill.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; align-items: center; }
textarea.code { width: 100%; min-height: 420px; font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; background: var(--code-bg); resize: vertical; tab-size: 2; }
textarea.plain { width: 100%; min-height: 90px; font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; }
.dirty { color: var(--warn); font-size: 12px; }

.shots { display: flex; flex-direction: column; gap: 12px; }
.shot h3 { margin: 0; }
.shot .meta { font-size: 12px; color: var(--muted); margin: 2px 0 6px; }
.shot iframe { width: 100%; height: 340px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.shot pre { white-space: pre-wrap; font-size: 12px; margin: 4px 0 0; }

.rule { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 10px; }
.rule.off { opacity: .65; }
.rule-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.rule-head input.name { flex: 1 1 200px; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 10px; }
.grid2 textarea { min-height: 54px; resize: vertical; }

.images { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.image { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.image .thumb { height: 90px; display: flex; align-items: center; justify-content: center; background: #fff; border-radius: 4px; border: 1px solid var(--line); }
.image img { max-width: 100%; max-height: 80px; }
.image code { font-size: 11px; overflow-wrap: anywhere; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .what { flex: 1; min-width: 0; overflow-wrap: anywhere; }

dialog { border: 1px solid var(--line); border-radius: 10px; padding: 0; background: var(--panel); color: var(--text); width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
dialog::backdrop { background: rgb(0 0 0 / .4); }
dialog form { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
dialog .actions { display: flex; gap: 8px; justify-content: flex-end; }

#toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; }
#toast.bad { background: var(--bad); color: #fff; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 80px; margin: 10px 0 4px; border-bottom: 1px solid var(--line); }
.bar { flex: 1; min-height: 1px; background: var(--accent, #0c8282); border-radius: 2px 2px 0 0; }
table.clicks { border-collapse: collapse; margin: 8px 0; }
table.clicks td, table.clicks th { padding: 2px 14px 2px 0; text-align: left; }
input:disabled, textarea:disabled, select:disabled { opacity: .6; cursor: not-allowed; }
pre.diff { max-height: 420px; overflow: auto; background: var(--code-bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; font-size: 12px; white-space: pre-wrap; }

/* ---- Precinct Signatures branding (header, footer, public pages) ---- */
.brand { display: inline-flex; align-items: center; gap: 8px; }
.brand .logo { width: 26px; height: 26px; flex: none; }
.brand-name { font-weight: 700; color: var(--text); }
.brand-by { font-weight: 400; font-size: 12px; color: var(--muted); }
.top-link { font-size: 13px; text-decoration: none; }
.foot { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; padding: 14px 16px; margin-top: 24px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); background: var(--panel); }
.foot a { color: var(--muted); }
.foot a:hover { color: var(--accent); }
body.public { min-height: 100vh; display: flex; flex-direction: column; }
body.public main { flex: 1; width: 100%; }
main.narrow { max-width: 760px; }
.hero { text-align: center; padding: 28px 0 8px; }
.hero h1 { font-size: 28px; }
.lead { font-size: 16px; color: var(--muted); max-width: 46em; margin: 8px 0 16px; }
.hero .lead { margin: 8px auto 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin: 0 0 16px; }
.signin { max-width: 440px; margin: 8px auto 16px; }
.signin label { font-size: 13px; }
.signin input { padding: 9px 10px; font-size: 15px; }
a.button { display: inline-block; text-decoration: none; text-align: center; border-radius: 6px; padding: 9px 14px; border: 1px solid var(--line); }
a.button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.wide { width: 100%; padding: 10px 14px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.small { font-size: 12px; }
.banner.good { background: var(--good-bg); color: var(--good); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.contact { list-style: none; padding: 0; margin: 0 0 8px; line-height: 1.9; }
.legal h2 { font-size: 15px; margin-top: 18px; }
.legal p, .legal li { max-width: 70ch; }
body { min-height: 100vh; display: flex; flex-direction: column; }
body > main { flex: 1; width: 100%; }
