:root {
  color-scheme: light;
  --ink: #071d37;
  --ink-soft: #143955;
  --paper: #f5f2e9;
  --paper-bright: #fbfaf6;
  --mist: #d6e3e9;
  --blue: #6e98ae;
  --gold: #d9ad4d;
  --red: #bd493b;
  --muted: #65717a;
  --line: rgb(7 29 55 / 18%);
  --safe-edge: clamp(1.5rem, 2vw, 2.5rem);
  font-family: "Avenir Next", Avenir, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

html {
  background: transparent;
}

body {
  color: var(--ink);
  background: linear-gradient(135deg, rgb(251 250 246 / 92%), rgb(245 242 233 / 92%));
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: var(--ink-soft);
  text-underline-offset: .18em;
}

.site-header {
  min-height: 10rem;
  padding: 2rem var(--safe-edge);
  color: var(--paper-bright);
  background: var(--ink);
  border-bottom: 3px solid var(--gold);
}

.site-header h1,
.site-header p {
  margin: 0;
}

.site-header h1 {
  margin-block: .2rem .4rem;
  font-size: clamp(2rem, 4vw, 4rem);
  font-weight: 550;
  letter-spacing: -.04em;
}

.site-header > p:last-child {
  max-width: 56rem;
  color: var(--mist);
  font-size: 1.05rem;
}

.eyebrow {
  margin: 0 0 .35rem;
  color: var(--gold);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
}

.manager-layout,
.status-layout,
.detail-layout {
  width: auto;
  margin: 2rem var(--safe-edge) 4rem;
}

html[data-obs-layout="full"] .status-layout,
html[data-obs-layout="full"] .detail-layout {
  margin-left: clamp(8rem, 9vw, 11rem);
}

.panel {
  margin-bottom: 1.5rem;
  padding: clamp(1rem, 2.6vw, 2rem);
  background: rgb(251 250 246 / 93%);
  border: 1px solid var(--line);
  box-shadow: 0 1.2rem 3rem rgb(7 29 55 / 8%);
}

.notice {
  margin-bottom: 1rem;
  padding: .9rem 1.1rem;
  border-left: .35rem solid var(--blue);
  background: var(--paper-bright);
}

.notice.warning {
  border-color: var(--gold);
}

.notice.success {
  border-color: #5c9e47;
}

.notice.error {
  border-color: var(--red);
}

.dataset-switcher {
  display: grid;
  grid-template-columns: auto minmax(16rem, 34rem);
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.dataset-switcher label,
.time-field {
  font-weight: 650;
}

.time-input-group {
  display: grid;
  gap: .45rem;
}

.clock-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .4rem;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 500;
}

select,
input[type="text"],
input[type="url"],
input[type="date"],
input[type="datetime-local"],
input[type="number"],
textarea {
  padding: .72rem .8rem;
  color: var(--ink);
  background: white;
  border: 1px solid rgb(7 29 55 / 30%);
  border-radius: .25rem;
}

textarea {
  resize: vertical;
}

.section-intro {
  margin: -.35rem 0 1rem;
  color: var(--muted);
}

.forecast-list {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  margin-bottom: 1.25rem;
}

.forecast-list a {
  padding: .45rem .7rem;
  background: var(--mist);
  border-radius: 999px;
  text-decoration: none;
}

.create-forecast,
.forecast-metadata {
  border-top: 1px solid var(--line);
}

.create-forecast summary,
.forecast-metadata summary {
  padding: 1rem 0;
  font-weight: 700;
  cursor: pointer;
}

.forecast-metadata {
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}

.metadata-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  padding: .5rem 0 1rem;
}

.metadata-form.compact {
  padding-top: 0;
}

.field {
  display: grid;
  align-content: start;
  gap: .4rem;
  font-weight: 650;
}

.field small {
  color: var(--muted);
  font-weight: 400;
}

.field-wide {
  grid-column: 1 / -1;
}

.dataset-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 1.75rem;
  border-block: 1px solid var(--line);
}

.dataset-summary div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-right: 1px solid var(--line);
}

.dataset-summary div:last-child {
  border-right: 0;
}

.dataset-summary span {
  color: var(--muted);
}

.time-field {
  display: grid;
  grid-template-columns: minmax(14rem, 1fr) minmax(15rem, 22rem);
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.party-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .65rem;
}

.party-input {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 5rem;
  padding: .8rem 1rem .8rem 1.2rem;
  background: white;
  border: 1px solid var(--line);
  border-left: .45rem solid var(--party-color);
}

.party-input > span:first-child {
  display: grid;
  gap: .15rem;
}

.party-input strong {
  font-size: 1.15rem;
}

.party-input small {
  color: var(--muted);
}

.number-field {
  display: flex;
  align-items: center;
  gap: .35rem;
}

.number-field input {
  width: 7rem;
  text-align: right;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1.5rem;
  margin-top: 1.25rem;
}

.form-actions p {
  margin: 0;
}

#share-total[data-valid="false"] {
  color: var(--red);
}

.form-actions button {
  padding: .85rem 1.4rem;
  color: white;
  font-weight: 700;
  background: var(--ink);
  border: 0;
  border-radius: .25rem;
  cursor: pointer;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.8rem;
}

.history-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-list li {
  display: grid;
  grid-template-columns: 5rem 1fr;
  gap: 1rem;
  padding: .85rem 0;
  border-top: 1px solid var(--line);
}

.history-list time {
  font-size: 1.1rem;
  font-weight: 700;
}

.history-list span {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem .65rem;
}

.history-list b {
  margin-left: .5rem;
}

.empty-state {
  padding: 2rem;
  color: var(--muted);
  text-align: center;
  border: 1px dashed rgb(7 29 55 / 25%);
}

.status-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
}

.page-status {
  flex: none;
  padding-bottom: .3rem;
  color: var(--mist) !important;
  font-variant-numeric: tabular-nums;
}

.page-status[data-state="error"] {
  color: #f2b5ac !important;
}

.readout-layout {
  margin-top: var(--safe-edge);
}

.detail-layout.readout-layout {
  margin-bottom: var(--safe-edge);
}

.detail-page[data-view="latest"] .detail-layout,
.detail-page[data-view="history"] .detail-layout {
  min-height: calc(100vh - (2 * var(--safe-edge)));
  align-content: center;
}

.detail-page[data-pause="true"] .detail-layout {
  align-content: start;
}

.detail-page[data-pause="true"] {
  background: linear-gradient(135deg, rgb(251 250 246 / 92%), rgb(245 242 233 / 92%));
}

.detail-page[data-pause="true"] .detail-heading-actions a {
  display: none;
}

.counting-pause-message {
  margin: 0 0 1.75rem;
  padding-bottom: 1.25rem;
  color: var(--ink);
  font-size: clamp(2.4rem, 5vw, 5rem);
  font-weight: 550;
  letter-spacing: -.035em;
  line-height: 1;
  text-align: center;
  border-bottom: 3px solid var(--gold);
}

.readout-status {
  margin: 0 0 .55rem;
  color: var(--muted);
  font-size: .78rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.readout-status[data-state="error"] {
  color: var(--red);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.forecast-detail-heading {
  align-items: end;
}

.forecast-detail-heading h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.8rem);
  line-height: 1;
  letter-spacing: -.035em;
}

.forecast-detail-heading .forecast-source {
  margin: .45rem 0 0;
  color: var(--muted);
  font-size: .85rem;
}

.forecast-detail-heading .forecast-source a {
  color: var(--ink-soft);
}

.detail-heading-actions {
  display: grid;
  justify-items: end;
  gap: .45rem;
}

.detail-heading-actions .readout-status {
  margin: 0;
}

.status-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 34rem), 1fr));
  gap: 1.4rem;
}

.dataset-card {
  margin: 0;
}

.dataset-card-header,
.dataset-card-footer {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.dataset-card-header {
  margin-bottom: 1.25rem;
}

.dataset-card-header h2 {
  margin: 0;
  font-size: clamp(1.65rem, 3vw, 2.5rem);
  font-weight: 550;
}

.party-rows {
  border-block: 1px solid var(--line);
}

.party-row {
  display: grid;
  grid-template-columns: 5.5rem minmax(8rem, 1fr) minmax(8rem, 1.3fr) 4.8rem;
  align-items: center;
  gap: .7rem;
  min-height: 3.35rem;
  border-bottom: 1px solid var(--line);
}

.party-row:last-child {
  border-bottom: 0;
}

.party-abbreviation {
  padding-left: .75rem;
  border-left: .35rem solid var(--party-color);
}

.party-name {
  overflow: hidden;
  color: var(--muted);
  font-size: .8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.party-bar {
  height: .6rem;
  overflow: hidden;
  background: rgb(7 29 55 / 8%);
  border-radius: 1rem;
}

.party-bar i {
  display: block;
  height: 100%;
  background: var(--party-color);
  border-radius: inherit;
}

.party-value {
  text-align: right;
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
}

.dataset-card-footer {
  align-items: center;
  margin-top: 1rem;
  color: var(--muted);
  font-size: .85rem;
}

.data-error-card {
  min-height: 14rem;
  border-top: .35rem solid var(--red);
}

.comparison-panel {
  padding: 0;
  overflow: hidden;
}

.comparison-scroll {
  overflow-x: auto;
}

.comparison-table {
  width: 100%;
  min-width: 55rem;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.comparison-table th,
.comparison-table td {
  min-width: 11rem;
  padding: 1rem 1.1rem;
  text-align: right;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.comparison-table th:first-child,
.comparison-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 13rem;
  text-align: left;
  background: var(--paper-bright);
}

.comparison-table thead th {
  vertical-align: top;
  color: var(--paper-bright);
  background: var(--ink);
}

.comparison-table thead th:first-child {
  z-index: 2;
  color: var(--paper-bright);
  background: var(--ink);
}

.comparison-table tbody tr:nth-child(odd) > * {
  background: var(--paper-bright);
}

.comparison-table tbody tr:nth-child(even) > * {
  background: #e9eff0;
}

.comparison-table th:last-child,
.comparison-table td:last-child {
  border-right: 0;
}

.comparison-column-title {
  display: block;
  color: inherit;
  font-size: 1rem;
}

.comparison-column-source,
.comparison-column-time {
  display: block;
  margin-top: .35rem;
  color: var(--mist);
  font-size: .72rem;
  font-weight: 400;
}

.comparison-column-source a {
  color: var(--gold);
}

.comparison-party {
  display: flex;
  align-items: center;
  gap: .65rem;
}

.comparison-party::before {
  width: .35rem;
  height: 1.7rem;
  background: var(--party-color);
  content: "";
}

.comparison-party small {
  display: block;
  color: var(--muted);
  font-weight: 400;
}

.comparison-value {
  display: inline;
  font-size: 1.25rem;
  font-weight: 700;
}

.comparison-delta {
  display: inline;
  margin-left: .45rem;
  font-size: 1.25rem;
  font-weight: 700;
  opacity: .72;
}

.is-positive {
  color: #4f804b;
}

.is-negative {
  color: #a85a52;
}

.is-neutral {
  color: var(--muted);
}

.comparison-missing {
  color: var(--muted);
}

.entry-page {
  min-height: 100vh;
  background: var(--ink);
}

.entry-layout {
  width: auto;
  margin: 0 var(--safe-edge);
  padding: 1.25rem 0 2rem;
}

.entry-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  padding: 1rem 0 1.25rem;
  color: var(--paper-bright);
  border-bottom: 2px solid var(--gold);
}

.entry-header h1,
.entry-header p {
  margin: 0;
}

.entry-header h1 {
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 1;
  letter-spacing: -.04em;
}

.entry-header > div > p:last-child {
  margin-top: .55rem;
  color: var(--mist);
}

.entry-dataset-switcher {
  display: grid;
  gap: .35rem;
  min-width: 22rem;
}

.entry-dataset-switcher label {
  color: var(--gold);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.entry-message {
  margin-top: 1rem;
  padding: .8rem 1rem;
  color: var(--paper-bright);
  border-left: .35rem solid var(--gold);
  background: rgb(255 255 255 / 8%);
}

.entry-message.success {
  border-color: #5c9e47;
}

.entry-message.error {
  border-color: var(--red);
}

.focused-entry-form {
  margin-top: 1rem;
}

.focused-party-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .6rem;
}

.focused-party {
  display: grid;
  gap: .8rem;
  min-height: 7.4rem;
  padding: .85rem 1rem .85rem 1.2rem;
  color: var(--paper-bright);
  background: rgb(255 255 255 / 7%);
  border-left: .45rem solid var(--party-color);
}

.focused-party-name {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.focused-party-name strong {
  font-size: 1.35rem;
}

.focused-party-name small {
  color: var(--mist);
}

.slider-control {
  display: grid;
  grid-template-columns: 3.25rem minmax(8rem, 1fr) 3.25rem 5.4rem;
  align-items: center;
  gap: .7rem;
}

.slider-control input[type="range"] {
  width: 100%;
  min-width: 0;
  accent-color: var(--party-color);
  cursor: pointer;
  touch-action: pan-x;
}

.step-button {
  width: 3.25rem;
  height: 3.25rem;
  padding: 0;
  color: var(--paper-bright);
  font-size: 1.6rem;
  line-height: 1;
  background: rgb(255 255 255 / 12%);
  border: 1px solid rgb(255 255 255 / 22%);
  border-radius: .35rem;
  cursor: pointer;
  touch-action: manipulation;
}

.step-button:active {
  background: var(--party-color);
}

.slider-control output {
  color: var(--paper-bright);
  font-size: 1.15rem;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.focused-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2rem;
  margin-top: 1rem;
  color: var(--paper-bright);
}

.focused-actions p {
  margin: 0;
  font-size: 1.15rem;
}

.focused-actions button {
  padding: 1rem 2.4rem;
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 800;
  background: var(--gold);
  border: 0;
  border-radius: .25rem;
  cursor: pointer;
}

#share-total[data-valid="false"] {
  color: #f2b5ac;
}

.latest-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-block: 1px solid var(--line);
}

.latest-grid div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  box-shadow: inset .35rem 0 var(--party-color);
}

.latest-grid div:nth-child(4n) {
  border-right: 0;
}

.latest-grid strong {
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
}

.latest-value {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: .5rem;
}

.latest-value small {
  font-size: 1.3rem;
  font-weight: 700;
  opacity: .72;
}

.graph-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .45rem 1rem;
  max-width: 50rem;
}

.graph-legend span {
  padding-left: .8rem;
  border-left: .3rem solid var(--party-color);
  font-size: .82rem;
  font-weight: 700;
}

.forecast-graph {
  display: block;
  width: 100%;
  height: auto;
  max-height: 500px;
  overflow: visible;
}

.forecast-graph .grid-line {
  stroke: rgb(7 29 55 / 14%);
  stroke-width: 1;
}

.forecast-graph .axis-label {
  fill: var(--muted);
  font-family: inherit;
  font-size: 18px;
}

@media (max-width: 800px) {
  .dataset-switcher,
  .time-field,
  .party-inputs,
  .metadata-form,
  .focused-party-grid {
    grid-template-columns: 1fr;
  }

  .entry-header {
    align-items: stretch;
    flex-direction: column;
  }

  .entry-dataset-switcher {
    min-width: 0;
  }

  .dataset-summary {
    grid-template-columns: 1fr;
  }

  .dataset-summary div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .form-actions,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .status-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .party-row {
    grid-template-columns: 4.5rem 1fr 4.5rem;
  }

  .party-name {
    display: none;
  }

  .latest-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .latest-grid div:nth-child(2n) {
    border-right: 0;
  }
}
