/* Mandate — quiet surfaces, typographic hierarchy, iOS-caliber controls. */
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --fill: #f2f2f4;
  --fill-2: #e8e8ed;
  --hairline: rgba(0, 0, 0, .09);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --faint: #a1a1a6;
  --accent: #0071e3;
  --accent-tint: rgba(0, 113, 227, .10);
  --green: #34c759;
  --green-text: #1d9d49;
  --green-tint: rgba(52, 199, 89, .15);
  --red: #ff3b30;
  --red-text: #d70015;
  --red-tint: rgba(255, 59, 48, .12);
  --track: #e4e4e9;
  --r-card: 18px;
  --r-ctl: 12px;
  --shadow-hover: 0 12px 32px rgba(0, 0, 0, .09);
  --ease: cubic-bezier(.25, .1, .25, 1);
  --header-bg: rgba(251, 251, 253, .82);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  /* aliases used from JS inline styles and the sparkline */
  --approve: var(--green-text);
  --disapprove: var(--red-text);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --fill: #2c2c2e;
    --fill-2: #3a3a3c;
    --hairline: rgba(255, 255, 255, .14);
    --text: #f5f5f7;
    --muted: #98989d;
    --faint: #69696e;
    --accent: #0a84ff;
    --accent-tint: rgba(10, 132, 255, .16);
    --green: #30d158;
    --green-text: #30d158;
    --green-tint: rgba(48, 209, 88, .16);
    --red: #ff453a;
    --red-text: #ff453a;
    --red-tint: rgba(255, 69, 58, .16);
    --track: #3a3a3c;
    --shadow-hover: 0 12px 32px rgba(0, 0, 0, .5);
    --header-bg: rgba(22, 22, 23, .8);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.47;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font: inherit; color: inherit; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 1.375rem; }

/* ---------- header ---------- */
header.site {
  position: sticky; top: 0; z-index: 20;
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
}

.site-inner {
  display: flex; align-items: center; gap: 1.25rem;
  height: 52px; padding: 0 1.375rem;
  max-width: 1040px; margin: 0 auto;
}

.brand {
  color: var(--text); font-size: 1.18rem; font-weight: 700;
  letter-spacing: -.022em; text-decoration: none;
}
.brand:hover { text-decoration: none; }

.country-select {
  margin-left: auto;
  appearance: none; -webkit-appearance: none;
  border: none; background: var(--fill);
  color: var(--text); font: inherit; font-size: .84rem; font-weight: 500;
  padding: .34rem 1.7rem .34rem .8rem; border-radius: 980px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236e6e73' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center;
  transition: background-color .2s var(--ease);
}
.country-select:hover { background-color: var(--fill-2); }
.country-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

nav.tabs { display: flex; gap: .15rem; }

nav.tabs button {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: .84rem; font-weight: 500;
  padding: .38rem .7rem; border-radius: 980px;
  transition: color .2s var(--ease), background-color .2s var(--ease);
}
nav.tabs button:hover { color: var(--text); }
nav.tabs button[aria-current="page"] { color: var(--text); background: var(--fill); }

/* ---------- page head ---------- */
.page-head { margin: 2.4rem 0 1.6rem; }
.page-head h1 {
  margin: 0; font-size: 2.1rem; line-height: 1.12;
  font-weight: 700; letter-spacing: -.025em;
}
.footnote { margin: .45rem 0 0; color: var(--muted); font-size: .84rem; }

/* ---------- filters ---------- */
.filters {
  display: grid; grid-template-columns: 1.7fr repeat(3, 1fr); gap: .55rem;
  margin: 0 0 1rem;
}
@media (max-width: 720px) { .filters { grid-template-columns: 1fr 1fr; } .filters .search { grid-column: 1 / -1; } }

.filters input, .filters select {
  width: 100%; padding: .58rem .85rem;
  border: none; border-radius: var(--r-ctl);
  background: var(--surface); color: var(--text); font: inherit; font-size: .9rem;
  box-shadow: 0 0 0 1px var(--hairline) inset;
  transition: box-shadow .2s var(--ease);
}
@media (prefers-color-scheme: dark) {
  .filters input, .filters select { background: var(--surface); }
}
.filters input::placeholder { color: var(--faint); }
.filters input:focus, .filters select:focus {
  outline: none; box-shadow: 0 0 0 2px var(--accent) inset;
}
.filters select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236e6e73' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .8rem center;
  padding-right: 2rem; cursor: pointer;
}

.result-line {
  display: flex; align-items: center; gap: .5rem;
  color: var(--faint); font-size: .8rem; margin-bottom: .8rem;
}
.result-line .sort { margin-left: auto; }
.result-line select {
  border: none; background: none; color: var(--muted);
  font: inherit; font-size: .8rem; font-weight: 500; cursor: pointer;
  padding: .2rem 1.4rem .2rem .4rem; border-radius: 8px;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='5' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236e6e73' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .35rem center;
}
.result-line select:hover { color: var(--text); }

/* ---------- cards ---------- */
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: .9rem; padding-bottom: 4rem;
}

.card {
  text-align: left; width: 100%;
  background: var(--surface); border: none; border-radius: var(--r-card);
  padding: 1.15rem 1.25rem 1.05rem; cursor: pointer;
  display: flex; flex-direction: column; gap: .85rem;
  transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.card:active { transform: scale(.985); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.card-head { display: flex; align-items: flex-start; gap: .9rem; }
.card-id { min-width: 0; flex: 1; }

.card h3 {
  margin: 0; font-size: 1.05rem; font-weight: 600; letter-spacing: -.014em;
  line-height: 1.25;
}
.card .role { font-size: .8rem; color: var(--muted); margin-top: .1rem; }

.card-pct { text-align: right; flex: 0 0 auto; }
.card-pct b {
  display: block; font-size: 1.45rem; font-weight: 650; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.card-pct span { font-size: .68rem; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; }

.card-meta {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  font-size: .78rem; color: var(--muted);
}
.card-party { display: inline-flex; align-items: center; gap: .42rem; min-width: 0; }
.card-party > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dot {
  width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; display: inline-block;
}

.you-chip { color: var(--accent); font-weight: 500; white-space: nowrap; }
.card-meta > span:last-child { white-space: nowrap; }

/* ---------- approval bar ---------- */
.bar {
  height: 4px; border-radius: 980px; background: var(--track);
  overflow: hidden; display: flex;
}
.bar > i {
  display: block; background: var(--green); height: 100%; border-radius: 980px;
  transition: width .5s var(--ease);
}

.bar-legend {
  display: flex; justify-content: space-between; gap: .75rem;
  font-size: .78rem; color: var(--muted);
}
.bar-legend b { font-variant-numeric: tabular-nums; font-weight: 600; }
.pos { color: var(--green-text); }
.neg { color: var(--red-text); }

/* ---------- grouped lists ---------- */
.rank-list {
  list-style: none; margin: 0 0 4rem; padding: 0;
  background: var(--surface); border-radius: var(--r-card); overflow: hidden;
}
.rank-list li + li .rank-row { border-top: 1px solid var(--hairline); }

.rank-row {
  display: flex; align-items: center; gap: .9rem;
  width: 100%; text-align: left; color: inherit;
  padding: .85rem 1.25rem; background: none; border: none; cursor: pointer;
  transition: background-color .15s var(--ease);
}
.rank-row:hover { background: var(--fill); }
.rank-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.rank-num {
  font-variant-numeric: tabular-nums; color: var(--faint);
  width: 1.6rem; font-size: .84rem; font-weight: 500; flex: 0 0 auto;
}
.rank-main { min-width: 0; flex: 1; }
.rank-main strong { display: block; font-size: .95rem; font-weight: 600; letter-spacing: -.01em; }
.rank-main span {
  font-size: .78rem; color: var(--muted);
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rank-net {
  font-variant-numeric: tabular-nums; font-weight: 600; font-size: 1rem;
  text-align: right; flex: 0 0 auto;
}
.rank-net small { display: block; font-weight: 400; font-size: .68rem; color: var(--faint); }

.avatar {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--fill-2); color: var(--muted);
  font-weight: 600; font-size: .82rem; letter-spacing: .01em;
}

.empty { text-align: center; color: var(--faint); padding: 4rem 1rem; font-size: .92rem; }

/* ---------- sheet ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, .4);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: grid; place-items: end center; padding: 0;
  animation: fadeIn .25s var(--ease);
}
@media (min-width: 720px) { .backdrop { place-items: center; padding: 2rem; } }

@keyframes fadeIn { from { opacity: 0; } }
@keyframes sheetUp { from { opacity: 0; transform: translateY(24px); } }

.sheet {
  background: var(--surface); width: 100%; max-width: 620px;
  max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  border-radius: 22px 22px 0 0; padding: .6rem 1.4rem 1.4rem;
  animation: sheetUp .35s var(--ease);
}
@media (min-width: 720px) { .sheet { border-radius: 22px; padding-top: 1.4rem; } }

.grabber {
  width: 36px; height: 5px; border-radius: 980px;
  background: var(--fill-2); margin: 0 auto .9rem;
}
@media (min-width: 720px) { .grabber { display: none; } }

.sheet-head { display: flex; gap: .9rem; align-items: flex-start; }
.sheet-head h2 { margin: 0; font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.sheet-head .role { font-size: .84rem; color: var(--muted); margin-top: .15rem; }

.sheet-meta {
  display: inline-flex; align-items: center; gap: .42rem;
  font-size: .8rem; color: var(--muted); margin-top: .45rem;
}

.close {
  margin-left: auto; flex: 0 0 auto;
  background: var(--fill); border: none;
  width: 30px; height: 30px; border-radius: 50%;
  cursor: pointer; color: var(--muted); font-size: 1.05rem; line-height: 1;
  display: grid; place-items: center;
  transition: background-color .2s var(--ease);
}
.close:hover { background: var(--fill-2); color: var(--text); }

.stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  margin: 1.4rem 0 1.1rem; text-align: center;
}
.stats > .stat + .stat { border-left: 1px solid var(--hairline); }
.stat b {
  display: block; font-size: 1.55rem; font-weight: 650; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
.stat span { font-size: .7rem; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; }

.section-label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--faint); margin: 1.5rem 0 .6rem; font-weight: 600;
}

.spark { width: 100%; height: 88px; display: block; color: var(--faint); }

.verdicts { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.verdict {
  border: none; background: var(--fill); border-radius: 14px;
  padding: .8rem; cursor: pointer; color: var(--text);
  font-weight: 600; font-size: .95rem;
  transition: background-color .2s var(--ease), color .2s var(--ease), transform .15s var(--ease);
}
.verdict:hover { background: var(--fill-2); }
.verdict:active { transform: scale(.97); }
.verdict[aria-pressed="true"].approve { background: var(--green-tint); color: var(--green-text); }
.verdict[aria-pressed="true"].disapprove { background: var(--red-tint); color: var(--red-text); }

.issue-tags { display: flex; flex-wrap: wrap; gap: .45rem; }
.issue-tags button {
  border: none; background: var(--fill); color: var(--muted);
  border-radius: 980px; padding: .42rem .85rem; cursor: pointer; font-size: .82rem; font-weight: 500;
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.issue-tags button:hover { background: var(--fill-2); color: var(--text); }
.issue-tags button[aria-pressed="true"] { background: var(--accent-tint); color: var(--accent); }

textarea {
  width: 100%; min-height: 108px; resize: vertical; padding: .8rem .9rem;
  border: none; border-radius: var(--r-ctl); background: var(--fill);
  color: var(--text); font: inherit; font-size: .9rem; line-height: 1.5;
}
textarea::placeholder { color: var(--faint); }
textarea:focus { outline: none; box-shadow: 0 0 0 2px var(--accent) inset; }

.private-note {
  display: flex; gap: .5rem; align-items: flex-start;
  font-size: .76rem; color: var(--faint); margin-top: .55rem; line-height: 1.45;
}
.private-note .lock { flex: 0 0 auto; margin-top: .1rem; color: var(--faint); }
.private-note em { font-style: italic; }

.actions { display: flex; gap: .6rem; align-items: center; margin-top: 1.4rem; flex-wrap: wrap; }

.btn {
  border: none; background: var(--accent); color: #fff;
  padding: .6rem 1.35rem; border-radius: 980px; cursor: pointer;
  font-weight: 600; font-size: .92rem;
  transition: filter .2s var(--ease), transform .15s var(--ease), background-color .2s var(--ease);
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.97); }
.btn.ghost { background: var(--accent-tint); color: var(--accent); }
.btn.danger { background: var(--red-tint); color: var(--red-text); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.saved-msg { font-size: .82rem; font-weight: 500; }

.chip {
  font-size: .72rem; color: var(--faint);
}
.chip.mine { color: var(--faint); }

/* ---------- prose ---------- */
.prose { max-width: 680px; padding-bottom: 5rem; }
.prose h2 { font-size: 1.25rem; font-weight: 650; letter-spacing: -.018em; margin: 2.2rem 0 .5rem; }
.prose p, .prose li { color: var(--muted); font-size: .92rem; }
.prose li { margin: .35rem 0; }
.prose b { color: var(--text); font-weight: 600; }
.prose code { font-family: var(--mono); font-size: .85em; background: var(--fill); padding: .12rem .35rem; border-radius: 6px; }

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

footer.site {
  border-top: 1px solid var(--hairline);
  padding: 1.4rem 0 3rem; color: var(--faint); font-size: .78rem;
}

/* ---------- narrow screens ---------- */
@media (max-width: 640px) {
  .page-head { margin-top: 1.7rem; }
  .page-head h1 { font-size: 1.7rem; }
  .site-inner { flex-wrap: wrap; height: auto; gap: .4rem .9rem; padding: .55rem 1.375rem; }
  .country-select { margin-left: auto; max-width: 9.5rem; }
  nav.tabs {
    order: 3; width: 100%;
    overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    margin: 0 -1.375rem; padding: 0 1.375rem .2rem;
  }
  nav.tabs::-webkit-scrollbar { display: none; }
  nav.tabs button { white-space: nowrap; }
  .stats { margin: 1.1rem 0 .9rem; }
  .stat b { font-size: 1.3rem; }
  .verdicts { grid-template-columns: 1fr; }
  .sheet { padding-left: 1.1rem; padding-right: 1.1rem; }
  .rank-row { padding: .8rem 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}
