@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  color-scheme: light;
  --ink: #16241f;
  --muted: #77847e;
  --line: #e6ece8;
  --green: #087f5b;
  --green-dark: #075d45;
  --green-soft: #e9f5ef;
  --paper: #f5f8f6;
  --white: #fff;
  font-family: 'DM Sans', sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
.topbar { height: 76px; padding: 0 max(28px, calc((100vw - 1190px) / 2)); display: flex; align-items: center; justify-content: space-between; background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font: 800 16px Manrope, sans-serif; letter-spacing: -.4px; }
.brand-mark { display: grid; place-items: center; width: 35px; height: 35px; color: var(--green); background: white; border: 2px solid var(--green); border-radius: 50%; font: 800 17px Manrope, sans-serif; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font: 700 9px 'DM Sans', sans-serif; letter-spacing: 1.2px; }
.topbar-actions { display: flex; align-items: center; gap: 22px; }
.admin-link { color: var(--green); font-size: 12px; font-weight: 700; text-decoration: none; }
.admin-link:hover { color: var(--green-dark); text-decoration: underline; }
.share-link { color: var(--green); font-size: 12px; font-weight: 700; text-decoration: none; }
.share-link:hover { color: var(--green-dark); text-decoration: underline; }
.live-label { display: flex; align-items: center; gap: 8px; color: #547068; font-size: 12px; font-weight: 600; }
.live-label i { width: 8px; height: 8px; border-radius: 50%; background: #23a277; box-shadow: 0 0 0 4px #e6f5ee; }
.page-shell { max-width: 1190px; padding: 45px 28px 36px; margin: 0 auto; }
.intro { margin: 0 0 27px; }
.eyebrow { margin: 0 0 9px; color: var(--green); font-size: 10px; font-weight: 700; letter-spacing: 1.35px; }
h1, h2 { margin: 0; font-family: Manrope, sans-serif; letter-spacing: -.7px; }
h1 { font-size: clamp(30px, 4vw, 42px); line-height: 1.2; }
h2 { font-size: 19px; }
.intro-copy { margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.messages { margin-bottom: 18px; }
.notice { padding: 12px 15px; border-radius: 10px; font-size: 13px; }
.notice.success { color: #126248; background: #e7f5ed; }
.notice.error { color: #923b35; background: #fff0ee; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 15px; margin-bottom: 18px; }
.stat-card, .panel { background: var(--white); border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 3px 12px #143c2810; }
.stat-card { min-height: 128px; padding: 19px 21px; }
.stat-card > span { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.stat-card > strong { display: block; margin: 9px 0 4px; font: 800 27px Manrope, sans-serif; letter-spacing: -.7px; }
.stat-card strong small { color: #98a39e; font-size: 15px; }
.stat-card > small { color: #99a39e; font-size: 11px; }
.stat-primary { color: white; background: var(--green); border-color: var(--green); }
.stat-primary > span, .stat-primary > small { color: #d5eee3; }
.leader-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 18px !important; }
.data-status-panel { margin-bottom: 18px; padding: 16px 20px; }
.data-status-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.data-status-heading h2 { font-size: 14px; }
.data-status-heading > span { color: var(--muted); font-size: 10px; }
.data-status-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.data-status-item { display: grid; grid-template-columns: 10px 1fr; grid-template-rows: auto auto; align-items: center; column-gap: 7px; padding: 9px; border: 1px solid var(--line); border-radius: 8px; }
.traffic-light { width: 9px; height: 9px; grid-row: 1 / span 2; border-radius: 50%; }
.data-status-item strong { font-size: 10px; }
.data-status-item small { margin-top: 2px; font-size: 9px; }
.has-data .traffic-light { background: #16815a; box-shadow: 0 0 0 3px #e5f3eb; }
.has-data small { color: #14704f; }
.no-data .traffic-light { background: #c94f49; box-shadow: 0 0 0 3px #fff0ee; }
.no-data small { color: #a0443e; }
.area-help { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.area-help summary { width: fit-content; color: var(--green); cursor: pointer; font-size: 10px; font-weight: 700; }
.area-help[open] summary { margin-bottom: 10px; }
.area-help-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px 16px; padding: 0; margin: 0; list-style: none; }
.area-help-grid li { display: grid; grid-template-columns: 15px 1fr; gap: 6px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.area-help-grid strong { color: var(--ink); }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(310px, .95fr); gap: 18px; align-items: stretch; }
.panel { padding: 22px 24px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.panel-heading .eyebrow { margin-bottom: 5px; }
.comparison-caption { margin: 6px 0 0; font-size: 10px; }
.pill { flex: 0 0 auto; padding: 7px 10px; color: #4f6c60; background: #f0f6f2; border-radius: 30px; font-size: 10px; font-weight: 700; }
.results-list { display: grid; gap: 15px; }
.result-row { display: grid; grid-template-columns: minmax(0, 1fr) 48px; gap: 8px 14px; align-items: center; }
.result-info { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }
.result-name { overflow: hidden; color: #304139; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.result-info strong { flex: 0 0 auto; font-size: 12px; }
.result-info strong small { color: #99a39e; font-size: 10px; font-weight: 500; }
.bar-track { height: 6px; overflow: hidden; grid-column: 1; background: #eef2ef; border-radius: 20px; }
.bar-fill { height: 100%; min-width: 0; background: #9ccdb8; border-radius: 20px; transition: width .25s ease; }
.bar-leader { background: var(--green); }
.result-percent { grid-column: 2; grid-row: 1 / span 2; color: #52675e; font-size: 11px; font-weight: 700; text-align: right; }
.comparison-line { display: flex; grid-column: 1 / -1; justify-content: space-between; gap: 8px; margin-top: -2px; color: #849189; font-size: 9px; line-height: 1.4; }
.change-pp { flex: 0 0 auto; color: #7b8780; font-size: 9px; }
.change-up { color: #137752; }
.change-down { color: #a2514b; }
.panel-footnote { margin: 18px 0 0; padding-top: 12px; color: #98a39e; border-top: 1px solid #f0f2f0; font-size: 10px; }
.empty-state { display: grid; justify-items: center; padding: 23px 10px 28px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 39px; height: 39px; margin-bottom: 10px; color: var(--green); background: var(--green-soft); border-radius: 50%; font-size: 20px; }
.empty-state strong { font-size: 13px; }
.empty-state p { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.muted { color: var(--muted); font-size: 12px; line-height: 1.55; }
.mapping-panel > .muted { margin: 10px 0 13px; }
.mapping-list { display: grid; gap: 12px; padding: 0; margin: 0; list-style: none; }
.mapping-list li { display: grid; grid-template-columns: 19px 1fr; gap: 8px; padding-top: 11px; border-top: 1px solid #f0f2f0; color: #43534b; font-size: 11px; line-height: 1.45; }
.mapping-arrow { color: var(--green); font-size: 17px; font-weight: 700; }
.mapping-list small { display: block; margin-top: 3px; color: #8b9690; font-size: 10px; }
.precinct-panel, .history-panel { margin-top: 18px; }
.precinct-panel .panel-heading { margin-bottom: 15px; }
.precinct-panel .panel-heading > .muted { margin: 0; text-align: right; }
.precinct-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.precinct-card { align-self: start; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.precinct-card[open] { border-color: #c9e1d4; box-shadow: 0 3px 12px #143c2809; }
.precinct-card summary { display: flex; align-items: center; gap: 10px; min-height: 66px; padding: 11px 12px; cursor: pointer; list-style: none; }
.precinct-card summary::-webkit-details-marker { display: none; }
.precinct-number { display: grid; place-items: center; flex: 0 0 34px; height: 34px; color: var(--green); background: var(--green-soft); border-radius: 9px; font: 800 12px Manrope, sans-serif; }
.precinct-title { display: grid; flex: 1 1 auto; gap: 3px; min-width: 0; }
.precinct-title strong { font-size: 12px; }
.precinct-title small { overflow: hidden; color: #929d97; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.status { padding: 5px 7px; color: #8c9691; background: #f3f5f4; border-radius: 20px; font-size: 9px; font-weight: 700; white-space: nowrap; }
.status-saved { color: #14704f; background: #e8f5ed; }
.chevron { color: #85918a; font-size: 16px; transition: transform .15s ease; }
.precinct-card[open] .chevron { transform: rotate(180deg); }
.vote-form { padding: 2px 12px 13px; border-top: 1px solid #eff2f0; }
.form-caption { padding: 11px 0; color: #78857e; font-size: 10px; font-weight: 600; }
.vote-input-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.vote-field { display: grid; align-content: start; gap: 5px; color: #65736b; font-size: 9px; font-weight: 600; }
.vote-field-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 5px; }
.historic-vote { flex: 0 0 auto; color: #19805d; font-size: 9px; font-weight: 700; white-space: nowrap; }
.historic-note { margin-top: -3px; color: #9aa49e; font-size: 8px; }
.precinct-history-note { margin: 10px 0 0; color: #8c9791; font-size: 9px; line-height: 1.4; }
.vote-field input { width: 100%; height: 34px; padding: 0 9px; color: var(--ink); background: #fbfcfb; border: 1px solid #e5ebe7; border-radius: 7px; outline: none; font: 600 12px 'DM Sans', sans-serif; }
.vote-field input:focus { border-color: #6daf90; box-shadow: 0 0 0 3px #e7f4ed; }
.form-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.save-time { color: #929c96; font-size: 9px; }
button { padding: 9px 12px; color: #fff; background: var(--green); border: 0; border-radius: 7px; cursor: pointer; font: 700 10px 'DM Sans', sans-serif; }
button:hover { background: var(--green-dark); }
button span { padding-left: 5px; font-size: 14px; }
.history-intro { margin: -5px 0 13px; }
.history-table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th { padding: 9px 10px; color: #89948e; border-bottom: 1px solid var(--line); font-size: 9px; font-weight: 700; text-align: left; text-transform: uppercase; letter-spacing: .5px; }
td { padding: 10px; border-bottom: 1px solid #f0f2f0; }
tbody tr:last-child td { border-bottom: 0; }
.numeric { text-align: right; white-space: nowrap; }
th.numeric { text-align: right; }
.history-note { color: #8b9690; font-size: 10px; }
footer { padding: 21px 2px 0; color: #9aa49e; font-size: 10px; text-align: center; }
.admin-topbar-actions { display: flex; align-items: center; gap: 14px; }
.admin-topbar-actions form { margin: 0; }
.admin-topbar-actions button { padding: 8px 10px; }
.admin-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; }
.admin-intro .intro { margin-bottom: 20px; }
.admin-precinct-panel { margin-top: 0; }
.login-shell { max-width: 470px; padding: 70px 20px; margin: 0 auto; }
.login-panel { padding: 27px; }
.login-panel h1 { font-size: 24px; }
.login-copy { margin: 9px 0 20px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.login-form { display: grid; gap: 12px; }
.login-form label { color: #65736b; font-size: 11px; font-weight: 700; }
.login-form input { width: 100%; height: 42px; padding: 0 11px; color: var(--ink); background: #fbfcfb; border: 1px solid #e5ebe7; border-radius: 7px; outline: none; font: 500 14px 'DM Sans', sans-serif; }
.login-form input:focus { border-color: #6daf90; box-shadow: 0 0 0 3px #e7f4ed; }
.login-form button { justify-self: start; padding: 10px 14px; font-size: 12px; }
.login-unconfigured { padding: 12px; color: #923b35; background: #fff0ee; border-radius: 8px; font-size: 12px; line-height: 1.5; }
.share-page { min-height: 100vh; background: var(--paper); }
.share-header { height: 58px; padding: 0 16px; }
.share-shell { max-width: 560px; padding: 17px 14px 22px; margin: 0 auto; }
.share-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.share-stat { min-height: 78px; padding: 11px 13px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.share-stat > span { display: block; color: var(--muted); font-size: 10px; font-weight: 600; }
.share-stat > strong { display: block; margin-top: 6px; font: 800 21px Manrope, sans-serif; }
.share-stat strong small { color: #98a39e; font-size: 12px; }
.share-stat-primary { color: #fff; background: var(--green); border-color: var(--green); }
.share-stat-primary > span { color: #d5eee3; }
.share-ranking-heading { display: flex; align-items: end; justify-content: space-between; gap: 10px; margin: 18px 2px 10px; }
.share-ranking-heading .eyebrow { margin-bottom: 4px; font-size: 9px; }
.share-ranking-heading h1 { font-size: 21px; }
.share-progress { display: grid; gap: 3px; padding-bottom: 2px; color: var(--muted); font-size: 10px; text-align: right; white-space: nowrap; }
.share-progress small { font-size: 8px; }
.share-list { display: grid; gap: 5px; padding: 0; margin: 0; list-style: none; }
.share-result { display: grid; grid-template-columns: 24px minmax(0, 1fr) 57px; align-items: center; gap: 9px; min-height: 43px; padding: 5px 10px; background: #fff; border: 1px solid var(--line); border-radius: 7px; }
.share-rank { color: var(--green); font: 800 12px Manrope, sans-serif; }
.share-party { display: grid; gap: 2px; min-width: 0; }
.share-party strong { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.share-party small { color: var(--muted); font-size: 9px; }
.share-party .share-change { color: #77847e; }
.share-party .share-change-up { color: #14704f; }
.share-party .share-change-down { color: #a0443e; }
.share-percent { color: var(--green-dark); font: 800 12px Manrope, sans-serif; text-align: right; white-space: nowrap; }
.share-result.share-under-five { color: #777f7b; background: #f0f2f1; border-color: #e4e7e5; }
.share-under-five .share-rank, .share-under-five .share-percent { color: #858d89; }
.share-under-five .share-party small { color: #929995; }
.share-result.share-leader { border-left: 3px solid var(--green); }
.share-footnote { margin: 9px 2px 0; color: var(--muted); font-size: 8px; line-height: 1.4; }

@media (max-width: 850px) {
  .content-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-card:last-child { grid-column: 1 / -1; min-height: 108px; }
  .data-status-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .topbar { height: 65px; padding: 0 18px; }
  .topbar-actions { gap: 12px; }
  .topbar-actions .live-label { display: none; }
  .topbar-actions .live-label { gap: 6px; font-size: 10px; }
  .page-shell { padding: 30px 15px; }
  .intro { margin-bottom: 21px; }
  .intro-copy { max-width: 390px; line-height: 1.5; }
  .stat-grid { gap: 9px; }
  .stat-card { min-height: 112px; padding: 14px; }
  .stat-card > strong { font-size: 22px; }
  .leader-name { font-size: 15px !important; }
  .panel { padding: 18px 15px; }
  .admin-topbar-actions { gap: 8px; }
  .admin-topbar-actions .admin-link { font-size: 10px; }
  .admin-topbar-actions button { padding: 7px 8px; font-size: 9px; }
  .login-shell { padding: 38px 15px; }
  .login-panel { padding: 21px 17px; }
  .panel-heading { align-items: flex-start; }
  .data-status-panel { padding: 15px; }
  .data-status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .area-help-grid { grid-template-columns: 1fr; }
  .precinct-grid { grid-template-columns: 1fr; }
  .precinct-panel .panel-heading { flex-direction: column; }
  .precinct-panel .panel-heading > .muted { text-align: left; }
  .result-info { font-size: 10px; }
  .history-note { min-width: 145px; }
  .share-header { height: 56px; padding: 0 15px; }
  .share-header .brand { font-size: 15px; }
  .share-shell { padding: 13px 12px 18px; }
  .share-stat { min-height: 72px; padding: 10px 11px; }
  .share-stat > strong { margin-top: 5px; font-size: 19px; }
  .share-ranking-heading { margin-top: 15px; }
  .share-ranking-heading h1 { font-size: 19px; }
  .share-result { grid-template-columns: 22px minmax(0, 1fr) 53px; min-height: 41px; gap: 7px; padding: 5px 8px; }
}