* {
  box-sizing: border-box;
}

:root {
  --color-bg: #0f172a;
  --color-surface: #1e293b;
  --color-surface-hover: #334155;
  --color-border: #334155;
  --color-text: #f1f5f9;
  --color-text-muted: #94a3b8;
  --color-primary: #3b82f6;
  --color-danger: #ef4444;
  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --radius: 8px;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  margin: 0 0 0.5rem;
  font-size: 2rem;
}

.subtitle {
  color: var(--color-text-muted);
  margin: 0 0 1.5rem;
}

.subtitle a {
  color: var(--color-text-muted);
}

.status-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.75rem;
  background: var(--color-surface);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}

.status-text {
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  max-width: 600px;
  margin: 0 auto;
}

.stat-card {
  background: var(--color-surface);
  padding: 1rem;
  border-radius: var(--radius);
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: bold;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 1.5rem;
  overflow-x: auto;
  padding-bottom: 0;
}

.tab {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  cursor: pointer;
  border-radius: var(--radius) var(--radius) 0 0;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
}

.tab:hover {
  color: var(--color-text);
  background: var(--color-surface);
}

.tab.active {
  color: var(--color-text);
  background: var(--color-surface);
  border-bottom: 2px solid var(--color-primary);
}

.badge {
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-weight: 500;
}

.badge.danger { background: var(--color-danger); color: white; }
.badge.success { background: var(--color-success); color: white; }
.badge.warning { background: var(--color-warning); color: black; }
.badge.neutral { background: var(--color-surface-hover); color: var(--color-text); }

/* Tab Panels */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.panel-header {
  margin-bottom: 1.5rem;
}

.panel-header h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.panel-header p {
  margin: 0 0 1rem;
  color: var(--color-text-muted);
}

.filter-input {
  width: 100%;
  max-width: 400px;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
}

.filter-input::placeholder {
  color: var(--color-text-muted);
}

.filter-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* Card Grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.mp-card {
  background: var(--color-surface);
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}

.mp-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.mp-card .party {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  margin-bottom: 0.5rem;
}

/* Party colors */
.party.labour,
.party.labour-co-operative { background: #dc241f; color: white; }
.party.conservative { background: #0087dc; color: white; }
.party.liberal-democrat { background: #fdbb30; color: black; }
.party.green,
.party.green-party { background: #6ab023; color: white; }
.party.snp,
.party.scottish-national-party { background: #fff95d; color: black; }
.party.plaid-cymru { background: #005b54; color: white; }
.party.dup,
.party.democratic-unionist-party { background: #d46a4c; color: white; }
.party.sinn-fein,
.party.sinn-féin { background: #326760; color: white; }
.party.independent { background: #888; color: white; }
.party.alliance { background: #f6cb2f; color: black; }
.party.sdlp { background: #2aa82c; color: white; }
.party.reform-uk { background: #12b6cf; color: white; }

.mp-card .constituency {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.bluesky-link {
  display: block;
  color: var(--color-primary);
  text-decoration: none;
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

.bluesky-link:hover {
  text-decoration: underline;
}

.confidence {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

.joined-date {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

.reason {
  font-size: 0.875rem;
  color: var(--color-warning);
  margin-top: 0.5rem;
}

.possible-match {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

/* Member cards (for list view) */
.profiles-grid {
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

.member-card {
  background: var(--color-surface);
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.avatar-placeholder {
  background: var(--color-surface-hover);
}

.member-info {
  min-width: 0;
}

.member-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-party {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  margin-block: 0.5rem;
}

.member-info a {
  color: var(--color-primary);
  text-decoration: none;
  font-size: 0.875rem;
  display: block
}

.member-info a:hover {
  text-decoration: underline;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--color-text-muted);
  grid-column: 1 / -1;
}

/* Hidden state for filtering */
.hidden {
  display: none !important;
}

/* Party Stats */
.party-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.party-stat-card {
  background: var(--color-surface);
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}

.party-stat-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.75rem;
}

.party-name {
  font-weight: 600;
  font-size: 1rem;
}

.party-count {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
}

.party-progress {
  height: 8px;
  background: var(--color-surface-hover);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.party-progress-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
  min-width: 2px;
}

/* Party progress bar colors */
.party-progress-bar.labour { background: #dc241f; }
.party-progress-bar.conservative { background: #0087dc; }
.party-progress-bar.liberal-democrat { background: #fdbb30; }
.party-progress-bar.snp { background: #fff95d; }
.party-progress-bar.plaid-cymru { background: #005b54; }
.party-progress-bar.green { background: #6ab023; }
.party-progress-bar.dup { background: #d46a4c; }
.party-progress-bar.sinn-fein { background: #326760; }
.party-progress-bar.alliance { background: #f6cb2f; }
.party-progress-bar.sdlp { background: #2aa82c; }
.party-progress-bar.reform-uk { background: #12b6cf; }
.party-progress-bar.independent { background: #888; }
.party-progress-bar.uup { background: #48a5ee; }
.party-progress-bar.speaker { background: #555; }

.party-stat-footer {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
}

.party-percentage {
  color: var(--color-success);
  font-weight: 500;
}

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

/* Footer */
footer {
  text-align: center;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

footer a {
  color: var(--color-primary);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

.build-info {
  font-size: 0.75rem;
  margin-top: 0.5rem;
}

/* Responsive */
@media (max-width: 640px) {
  .member-name {
    max-width: 20ch;
  }
  .tabs {
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .tab {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }

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