:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #d9e0e7;
  --text: #18222e;
  --muted: #657386;
  --accent: #0f766e;
  --accent-2: #b45309;
  --danger: #b42318;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.filters {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.brand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

h1, h2 {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0;
}

h1 { font-size: 22px; }
h2 { font-size: 15px; }

#dataStatus {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

input, select, button {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 7px 9px;
  font: inherit;
}

button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 650;
}

button.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

button:disabled {
  opacity: 0.55;
  cursor: default;
}

.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.actions button:first-child {
  grid-column: 1 / -1;
}

.content {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.metrics div,
.insights > div,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metrics div {
  padding: 13px 14px;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metrics strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
  line-height: 1.1;
}

.insights {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.insights > div {
  padding: 14px;
  min-height: 180px;
}

.bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 180px) 1fr 58px;
  gap: 10px;
  align-items: center;
}

.bar-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.bar-track {
  height: 9px;
  border-radius: 999px;
  background: #e8edf2;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
}

.bar-row strong {
  text-align: right;
  font-size: 12px;
}

.table-wrap {
  min-width: 0;
  overflow: hidden;
}

.table-head,
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

#pageInfo {
  color: var(--muted);
  font-size: 12px;
}

.table-scroll {
  overflow: auto;
  max-height: calc(100vh - 345px);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1180px;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
  line-height: 1.35;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
}

td.proposal {
  min-width: 320px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #e8f3f1;
  color: var(--accent);
}

.pill.against { background: #fdecec; color: var(--danger); }
.pill.abstain { background: #fff3dd; color: var(--accent-2); }
.pill.mixed { background: #eceff3; color: var(--muted); }

.pager {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}

.pager button {
  width: 96px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .filters {
    position: static;
    height: auto;
  }
  .metrics,
  .insights {
    grid-template-columns: 1fr;
  }
}
