* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: #07080d;
  color: #f6f7fb;
  font-family: 'Rajdhani', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

:root {
  --bg: #07080d;
  --bg-2: #10121a;
  --bg-3: #151827;
  --bg-4: rgba(255,255,255,0.03);
  --card: linear-gradient(180deg, rgba(21,24,39,0.94), rgba(11,13,22,0.94));
  --text: #f6f7fb;
  --muted: #a5acc3;
  --muted-2: #7c849e;
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.16);
  --accent: #60a5fa;
  --accent-2: #8b5cf6;
  --accent-soft: rgba(96,165,250,0.12);
  --success: #34d399;
  --danger: #fb7185;
  --warn: #f59e0b;
  --shadow: 0 16px 48px rgba(0,0,0,0.28);
  --radius: 16px;
  --radius-sm: 12px;
  --sidebar-width: 292px;
  --content-max: 1560px;
}

html[data-theme="light"] {
  --bg: #eff3f8;
  --bg-2: #ffffff;
  --bg-3: #e7edf5;
  --bg-4: rgba(15,23,42,0.04);
  --card: linear-gradient(180deg, rgba(255,255,255,0.99), rgba(247,250,252,0.99));
  --text: #0f172a;
  --muted: #475569;
  --muted-2: #5b6778;
  --border: rgba(15,23,42,0.12);
  --border-strong: rgba(15,23,42,0.2);
  --accent: #1d4ed8;
  --accent-2: #7c3aed;
  --accent-soft: rgba(29,78,216,0.10);
  --success: #047857;
  --danger: #dc2626;
  --warn: #b45309;
  --shadow: 0 16px 42px rgba(15,23,42,0.08);
}

a { color: var(--accent); text-decoration: none; }
a:hover { opacity: .92; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skip-link:focus {
  left: 16px;
  top: 16px;
  width: auto;
  height: auto;
  padding: .75rem 1rem;
  background: #fff;
  color: #111;
  border-radius: 8px;
  z-index: 2000;
}

.app-shell .shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  background:
    radial-gradient(circle at top left, rgba(96,165,250,0.13), transparent 36%),
    linear-gradient(180deg, #111321 0%, #090b12 100%);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  padding: 1rem;
  z-index: 1300;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  min-width: 0;
}
.brand a {
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}
.dot {
  color: var(--accent);
  font-size: 1rem;
}
.dot::before { content: '▶'; }

.sidebar-close,
.mobile-search-link,
.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-radius: 12px;
  min-height: 44px;
  min-width: 44px;
  cursor: pointer;
}
.sidebar-close { font-size: 1.55rem; }
.sidebar-search {
  margin-bottom: 1rem;
}
.sidebar-nav {
  display: grid;
  gap: .35rem;
  align-content: start;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-height: 46px;
  padding: .75rem .9rem;
  border-radius: 12px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: .02em;
  border: 1px solid transparent;
  transition: .18s ease;
}
.nav-item:hover {
  background: rgba(255,255,255,0.05);
  border-color: var(--border);
}
.nav-item.active {
  background: linear-gradient(90deg, rgba(96,165,250,0.18), rgba(139,92,246,0.14));
  border-color: rgba(96,165,250,0.32);
  color: #fff;
}
.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.sidebar-note {
  font-size: .92rem;
  color: var(--muted);
  margin: 0 0 .35rem;
}
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4,5,9,0.56);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: .18s ease;
  z-index: 1200;
}

.main-shell {
  min-height: 100vh;
  padding-left: var(--sidebar-width);
}
.mobile-topbar {
  display: none;
}
.container,
main.container {
  width: min(calc(100% - 2rem), var(--content-max));
  margin: 0 auto;
  padding: 1.5rem 0 2rem;
}
.footer {
  width: min(calc(100% - 2rem), var(--content-max));
  margin: 0 auto;
  padding: 1rem 0 2rem;
  color: var(--muted-2);
}
.footer-rule {
  margin-top: .85rem;
  padding-top: .85rem;
  border-top: 1px solid var(--border);
}

.quick-search { position: relative; width: 100%; max-width: none; }
.qs-box { position: relative; }
.qs-input,
input[type="text"],
input[type="email"],
input[type="search"],
input[type="date"],
select,
textarea,
.input {
  width: 100%;
  min-height: 46px;
  padding: .85rem .95rem;
  font-size: 16px !important;
  font-family: inherit;
  font-weight: 600;
  color: var(--text);
  background: rgba(255,255,255,0.035);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
}
.qs-input::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 1;
  font-weight: 600;
}
.qs-input:focus,
input:focus,
select:focus,
textarea:focus,
.input:focus {
  border-color: rgba(96,165,250,0.45);
  box-shadow: 0 0 0 4px rgba(96,165,250,0.12);
}
.qs-clear {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 1.2rem;
}
.qs-dropdown { position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 2000; }
.qs-items {
  background: rgba(8,10,17,0.98);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.qs-section { padding: .6rem .6rem .35rem; border-top: 1px solid rgba(255,255,255,0.05); }
.qs-section:first-child { border-top: 0; }
.qs-section-title { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: .35rem; font-weight: 700; }
.qs-row { display:block; padding: .7rem .75rem; border-radius: 10px; text-decoration:none; color: var(--text); }
.qs-row:hover { background: rgba(255,255,255,0.05); }
.qs-label { font-size: .95rem; font-weight: 700; }
.qs-meta { font-size: .8rem; color: var(--muted); margin-top: 2px; font-weight: 600; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 26px rgba(0,0,0,0.16);
  margin-bottom: 1rem;
}
.card.pad { padding: 1rem; }
.card.pad-lg { padding: 1.35rem; }
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .85rem;
}
.card-title { margin: 0 0 .25rem; font-size: 1.25rem; font-weight: 800; }
.card-meta, .subtle, .muted2 { color: var(--muted); font-weight: 600; }

.hero,
.hero-section {
  background:
    radial-gradient(circle at top right, rgba(96,165,250,0.16), transparent 32%),
    linear-gradient(180deg, rgba(20,24,39,0.98), rgba(10,12,20,0.98));
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 18px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.hero-title { font-size: clamp(1.75rem, 4vw, 2.75rem); margin: 0 0 .65rem; font-weight: 800; }
.hero-subtitle { font-size: 1rem; color: var(--muted); font-weight: 600; }

h1,h2,h3,h4 { color: var(--text); line-height: 1.15; }
h1 { font-size: clamp(1.9rem, 4vw, 3.1rem); margin: 0 0 .75rem; font-weight: 800; }
h2 { font-size: clamp(1.4rem, 2.8vw, 2rem); margin: 0 0 .7rem; font-weight: 800; }
h3 { font-size: clamp(1.05rem, 2vw, 1.25rem); margin: 0 0 .45rem; font-weight: 800; }
p { color: var(--text); }

.btn,
button,
input[type="submit"],
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 44px;
  padding: .75rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(96,165,250,0.35);
  background: rgba(96,165,250,0.1);
  color: #eef5ff;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.btn:hover,
button:hover,
.button:hover { background: rgba(96,165,250,0.16); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-height: 30px;
  padding: .25rem .75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
  font-size: .78rem;
  font-weight: 700;
}
.pill.good { background: rgba(52,211,153,0.12); border-color: rgba(52,211,153,0.26); color: var(--success); }
.pill.bad { background: rgba(251,113,133,0.12); border-color: rgba(251,113,133,0.26); color: var(--danger); }
.pill.warn { background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.26); color: var(--warn); }

.party-pill,
.pill.party { padding: .3rem .8rem; font-size: .8rem; font-weight: 700; border-radius: 999px; }
.party-pill.conservative,.pill.conservative { background: #0087DC; color: #fff; border-color: #0087DC; }
.party-pill.labour,.pill.labour { background: #E4003B; color: #fff; border-color: #E4003B; }
.party-pill.libdem,.pill.libdem { background: #FAA61A; color: #000; border-color: #FAA61A; }
.party-pill.snp,.pill.snp { background: #FDF38E; color: #000; border-color: #FDF38E; }
.party-pill.green,.pill.green { background: #6AB023; color: #fff; border-color: #6AB023; }
.party-pill.reform,.pill.reform { background: #12B6CF; color: #000; border-color: #12B6CF; }
.party-pill.plaid,.pill.plaid { background: #3F8428; color: #fff; border-color: #3F8428; }
.party-pill.dup,.pill.dup { background: #D46A4C; color: #fff; border-color: #D46A4C; }
.party-pill.sinnfein,.pill.sinnfein { background: #006A4D; color: #fff; border-color: #006A4D; }
.party-pill.independent,.pill.independent { background: #6B7280; color: #fff; border-color: #6B7280; }

.stats-grid,
.features-grid,
.mp-grid,
.party-grid,
.constituency-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0,1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stats-grid > *,
.features-grid > *,
.mp-grid > *,
.party-grid > *,
.constituency-grid > * { grid-column: span 3; }

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: 14px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: rgba(255,255,255,0.02);
}
thead { background: rgba(255,255,255,0.04); }
th, td {
  padding: .85rem .8rem;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
th {
  font-size: .78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 800;
}
td { color: #e6e8ef; font-weight: 600; }
tr:hover td { background: rgba(255,255,255,0.02); }

.hide-mobile { display: initial; }

@media (max-width: 1099px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .18s ease;
    width: min(88vw, 320px);
  }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .app-shell.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .main-shell { padding-left: 0; }
  .mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    min-height: 68px;
    padding: .85rem 1rem;
    background: rgba(10,12,19,0.92);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
  }
  .menu-toggle { padding: 0; }
  .menu-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    margin: 2px 0;
  }
  .brand-mobile { min-width: 0; }
  .brand-mobile a { font-size: 1.2rem; }
  .container,
  main.container,
  .footer { width: min(calc(100% - 1.25rem), 100%); }
  .container,
  main.container { padding: 1rem 0 1.5rem; }
  .stats-grid,
  .features-grid,
  .mp-grid,
  .party-grid,
  .constituency-grid {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }
  .stats-grid > *,
  .features-grid > *,
  .mp-grid > *,
  .party-grid > *,
  .constituency-grid > * { grid-column: span 1; }
  .hide-mobile { display: none !important; }
}

@media (max-width: 767px) {
  .hero,
  .hero-section { padding: 1.15rem; border-radius: 16px; }
  .card.pad, .card.pad-lg { padding: 1rem; }
  .card-header { flex-direction: column; }
  .stats-grid,
  .features-grid,
  .mp-grid,
  .party-grid,
  .constituency-grid {
    grid-template-columns: 1fr;
    gap: .85rem;
  }
  table { min-width: 640px; }
  th, td { padding: .75rem .7rem; }
}

html[data-theme="light"] body {
  background: var(--bg);
  color: var(--text);
}

html[data-theme="light"] .sidebar {
  background:
    radial-gradient(circle at top left, rgba(37,99,235,0.08), transparent 36%),
    linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 18px 46px rgba(15,23,42,0.08);
}

html[data-theme="light"] .mobile-topbar {
  background: rgba(255,255,255,0.94);
}

html[data-theme="light"] .quick-search .qs-items,
html[data-theme="light"] .qs-dropdown .qs-items {
  background: rgba(255,255,255,0.99);
}

html[data-theme="light"] .qs-row:hover,
html[data-theme="light"] tr:hover td {
  background: rgba(15,23,42,0.03);
}

html[data-theme="light"] table {
  background: rgba(255,255,255,0.85);
}

html[data-theme="light"] thead {
  background: rgba(15,23,42,0.04);
}

html[data-theme="light"] td {
  color: var(--text);
}

html[data-theme="light"] .btn,
html[data-theme="light"] button,
html[data-theme="light"] input[type="submit"],
html[data-theme="light"] .button {
  color: #0f172a;
  background: rgba(37,99,235,0.10);
  border-color: rgba(37,99,235,0.26);
}

html[data-theme="light"] .btn:hover,
html[data-theme="light"] button:hover,
html[data-theme="light"] .button:hover {
  background: rgba(37,99,235,0.14);
}

html[data-theme="light"] .pill {
  background: rgba(15,23,42,0.05);
}

html[data-theme="light"] .hero,
html[data-theme="light"] .hero-section {
  background:
    radial-gradient(circle at top right, rgba(37,99,235,0.10), transparent 32%),
    linear-gradient(180deg, rgba(255,255,255,0.99), rgba(248,250,252,0.99));
}

html[data-theme="light"] .card {
  box-shadow: 0 10px 30px rgba(15,23,42,0.06);
}

html[data-theme="light"] .subtle,
html[data-theme="light"] .muted2,
html[data-theme="light"] .card-meta,
html[data-theme="light"] th,
html[data-theme="light"] .hero-subtitle,
html[data-theme="light"] .qs-meta,
html[data-theme="light"] .sidebar-note {
  color: var(--muted);
  font-weight: 700;
}

html[data-theme="light"] input[type="text"],
html[data-theme="light"] input[type="email"],
html[data-theme="light"] input[type="search"],
html[data-theme="light"] input[type="date"],
html[data-theme="light"] select,
html[data-theme="light"] textarea,
html[data-theme="light"] .input,
html[data-theme="light"] .qs-input {
  background: rgba(15,23,42,0.04);
  border-color: rgba(15,23,42,0.14);
  color: var(--text);
  font-weight: 700;
}

html[data-theme="light"] input::placeholder,
html[data-theme="light"] textarea::placeholder,
html[data-theme="light"] .qs-input::placeholder {
  color: #64748b;
  opacity: 1;
  font-weight: 700;
}

html[data-theme="light"] .nav-item {
  color: #1f2937;
  font-weight: 700;
}

html[data-theme="light"] .nav-item.active {
  color: #0f172a;
}

html[data-theme="light"] .card-title,
html[data-theme="light"] h1,
html[data-theme="light"] h2,
html[data-theme="light"] h3,
html[data-theme="light"] h4,
html[data-theme="light"] .hero-title {
  color: var(--text);
  font-weight: 800;
}

.divisions-header {
margin-bottom:1rem;
}

.divisions-header h1{
margin-bottom:4px;
}

.divisions-header p{
color:var(--muted);
}

.filter-grid{
display:grid;
grid-template-columns:repeat(5,1fr);
gap:12px;
align-items:end;
}

.filter-actions{
display:flex;
gap:8px;
}

.division-table td{
vertical-align:middle;
}

.division-title a{
font-weight:700;
color:var(--text);
}

.axis-pill{
padding:4px 8px;
border-radius:6px;
font-size:12px;
color:white;
font-weight:700;
}

.result-pill{
padding:4px 8px;
border-radius:6px;
font-size:12px;
font-weight:700;
}

.result-pill.pass{
background:#16a34a;
color:white;
}

.result-pill.fail{
background:#dc2626;
color:white;
}

.division-count{
margin-bottom:10px;
color:var(--muted);
}

.pagination{
display:flex;
justify-content:center;
gap:20px;
margin-top:20px;
}

.pagination a{
font-weight:700;
}

@media (max-width:900px){

.filter-grid{
grid-template-columns:1fr 1fr;
}

.division-table{
font-size:14px;
}

}

/* ============================================
MP PROFILE HERO FIX (Light/Dark Mode)
Ensures text remains visible on dark gradient
============================================ */

.mp-hero,
.mp-hero * {
    color: #ffffff;
}

.mp-hero .mp-party-badge {
    color: #fff;
}

.mp-hero .mp-constituency {
    color: rgba(255,255,255,0.85);
}

.mp-hero .mp-name {
    color: #ffffff;
}

/* prevent theme overrides */
body.light-mode .mp-hero,
body.light-mode .mp-hero * {
    color: #ffffff !important;
}