/* Elmira Next: base styles. Colors are tokens on :root; dark mode redefines them. Bump ?v= in page_head() and
   admin.php when this file changes. */
:root {
  --bg: #f7f6f2; --surface: #ffffff; --text: #1d2327; --muted: #5f676d; --line: #e2e0d8;
  --brand: #0f3d3e; --brand-ink: #ffffff; --accent: #c8702a; --link: #0b6466;
  --coming: #1f5fa8; --coming-bg: #e6eef8; --opened: #237a3b; --opened-bg: #e5f3e8;
  --changed: #7a4aa0; --changed-bg: #f0e8f6; --closed: #8a3b2e; --closed-bg: #f6e7e4; --filed: #6b6f73; --filed-bg: #ececec;
  --ok-bg: #e5f3e8; --err-bg: #f8e3e0; --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121516; --surface: #1b2022; --text: #e7ebec; --muted: #9aa4a8; --line: #2c3437;
    --brand: #0c2f30; --link: #6cc6c8; --accent: #e39a5b;
    --coming: #8db8ec; --coming-bg: #1b2a3c; --opened: #85d39a; --opened-bg: #18301f;
    --changed: #c8a6e6; --changed-bg: #2b2236; --closed: #eca596; --closed-bg: #3a2420; --filed: #b5b9bc; --filed-bg: #2a2d2f;
    --ok-bg: #18301f; --err-bg: #3a2420; --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--font); }
a { color: var(--link); }
h1, h2, h3 { line-height: 1.25; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .9rem; }

/* Header */
.masthead { background: var(--brand); color: var(--brand-ink); border-bottom: 4px solid var(--accent); }
.masthead-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; padding-top: 14px; padding-bottom: 14px; }
.brand { color: inherit; text-decoration: none; display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-size: 1.6rem; font-weight: 800; letter-spacing: -.01em; }
.brand-tag { font-size: .9rem; opacity: .85; }
.nav { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; }
.nav a { color: inherit; text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; }
.nav a:hover, .nav a[aria-current] { border-bottom-color: var(--accent); }
.nav .count { background: var(--accent); color: #fff; border-radius: 99px; padding: 0 7px; font-size: .8rem; }

/* Intro and stats */
.intro { padding: 24px 0 8px; }
.intro h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); margin: 0 0 8px; }
.intro p { max-width: 46rem; }
.narrow { max-width: 42rem; }
.stats { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 8px 20px; }
.stats strong { font-size: 1.3rem; }

/* Filters */
.filters { margin: 12px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { display: inline-block; padding: 5px 12px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface);
        color: var(--text); text-decoration: none; font-size: .92rem; }
.chip[aria-current] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

/* Cards */
.month { font-size: 1.1rem; margin: 24px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.card, .lead { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.card { border-left: 4px solid var(--line); }
.card.kind-coming { border-left-color: var(--coming); } .card.kind-opened { border-left-color: var(--opened); }
.card.kind-changed { border-left-color: var(--changed); } .card.kind-closed { border-left-color: var(--closed); }
.card h3 { margin: 6px 0 4px; font-size: 1.1rem; overflow-wrap: anywhere; }
.card h3 a { color: var(--text); text-decoration: none; }
.card h3 a:hover { text-decoration: underline; }
.card p { margin: 4px 0; }
.card-top { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: .88rem; color: var(--muted); margin: 0; }
.place { color: var(--muted); }
.summary { font-size: .95rem; }
.cat { font-size: .85rem; color: var(--muted); }
.badge { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: .8rem; font-weight: 700; }
.badge-coming { color: var(--coming); background: var(--coming-bg); } .badge-opened { color: var(--opened); background: var(--opened-bg); }
.badge-changed { color: var(--changed); background: var(--changed-bg); } .badge-closed { color: var(--closed); background: var(--closed-bg); }
.badge-filed { color: var(--filed); background: var(--filed-bg); }
.empty { padding: 24px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.pager { display: flex; justify-content: space-between; margin: 24px 0; }

/* Item page */
.crumbs { margin: 16px 0 0; font-size: .9rem; }
.item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin: 12px 0 24px; }
.item h1 { margin: 8px 0 4px; overflow-wrap: anywhere; }
.lead { margin: 0 0 12px; }
.item .lead, p.lead { font-size: 1.08rem; border: 0; padding: 0; box-shadow: none; background: none; }
.records ul { padding-left: 18px; }
.button, button { display: inline-block; font: inherit; font-size: .95rem; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--brand);
                  background: var(--brand); color: var(--brand-ink); text-decoration: none; cursor: pointer; }
@media (prefers-color-scheme: dark) { .button, button, .chip[aria-current] { background: #1f6b6d; border-color: #1f6b6d; } }
button.secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
button.danger { background: var(--surface); color: var(--closed); border-color: var(--closed); }
button.link { background: none; border: 0; color: inherit; padding: 0; text-decoration: underline; }
.town-list { list-style: none; padding: 0; columns: 3 200px; }
.town-list li { padding: 4px 0; }
.prose li { margin-bottom: 6px; }

/* Forms */
.form { display: grid; gap: 10px; margin: 12px 0; }
.form label { display: grid; gap: 4px; font-weight: 600; font-size: .92rem; }
.form label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); width: 100%; min-width: 0; }
input[type=checkbox] { width: auto; }
.form button { justify-self: start; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 10px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.ok, .error { padding: 10px 14px; border-radius: 8px; margin: 14px 0; }
.ok { background: var(--ok-bg); } .error { background: var(--err-bg); }

/* Admin */
.admin .lead h3 { margin: 6px 0 2px; }
.lead.strength-strong { border-left: 4px solid var(--accent); }
.lead.is-hidden { opacity: .6; }
.tag { display: inline-block; font-size: .8rem; background: var(--filed-bg); color: var(--filed); border-radius: 6px; padding: 0 6px; margin: 2px 4px 2px 0; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
form.inline { display: inline-flex; flex-wrap: wrap; gap: 6px; margin: 0; }
details summary { cursor: pointer; font-weight: 600; margin: 6px 0; }
details.weak { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin: 20px 0; }
table.list { width: 100%; border-collapse: collapse; margin: 12px 0; background: var(--surface); }
table.list th, table.list td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: .92rem; }
.good { color: var(--opened); } .bad { color: var(--closed); }
@media (max-width: 700px) { table.list { display: block; overflow-x: auto; } }

/* Footer */
.footer { margin-top: 40px; padding: 20px 0 32px; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }

/* Development watch, meetings, IDA table */
.badge-project { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.card.kind-project { border-left-color: var(--accent); }
.aside { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 16px 8px; margin: 8px 0 16px; }
.aside .month { margin-top: 12px; }
.meeting-list { list-style: none; padding: 0; margin: 0; }
.meeting-list li { padding: 4px 0; }
.meeting-list time { display: inline-block; min-width: 7.5em; font-weight: 600; }
.table-wrap { overflow-x: auto; margin: 12px 0; }
.table-wrap table.list { margin: 0; min-width: 860px; }
table.list .num { text-align: right; white-space: nowrap; }