:root {
  --bg: #f8f9fc;
  --surface: #ffffff;
  --primary: #1a1a2e;
  --accent: #4cc9f0;
  --accent-dark: #3a9bc4;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --chip-bg: #e8f4f8;
  --chip-hover: #d0eaf4;
  --result-hover: #f5f9ff;
  --pass: #059669;
  --fail: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

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

/* ── Header ───────────────────────────────────────────────────── */
header {
  margin-bottom: 2rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.logo h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.logo p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.stats-bar {
  display: flex;
  gap: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.stats-bar .stat {
  display: flex;
  gap: 0.3rem;
}

.stats-bar .stat strong {
  color: var(--text);
  font-weight: 600;
}

/* ── Search ───────────────────────────────────────────────────── */
.search-section {
  margin-bottom: 1rem;
}

.search-box {
  display: flex;
  gap: 0;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.4rem 0.4rem 0;
  transition: border-color 0.15s;
}

.search-box:focus-within {
  border-color: var(--accent);
}

.search-icon {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  flex-shrink: 0;
  margin: auto 0.75rem;
}

#search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1rem;
  font-family: inherit;
  padding: 0.5rem;
  background: transparent;
}

#search-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

#search-btn:hover { background: #2a2a4e; }

.query-types {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.types-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.type-chip {
  background: var(--chip-bg);
  border: none;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--primary);
  cursor: pointer;
  transition: background 0.15s;
}

.type-chip:hover { background: var(--chip-hover); }

/* ── Debug ────────────────────────────────────────────────────── */
.debug-bar {
  background: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  margin-bottom: 0.75rem;
  font-family: monospace;
}

/* ── Suggestions ──────────────────────────────────────────────── */
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.suggest-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.suggestion {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.suggestion:hover {
  border-color: var(--accent);
  background: var(--chip-bg);
}

/* ── Filters ──────────────────────────────────────────────────── */
.filters {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.filter-group label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.filter-group select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8rem;
  font-family: inherit;
  background: var(--surface);
  cursor: pointer;
}

.filter-checkbox {
  flex-direction: row;
  align-items: center;
  margin-top: 1.1rem;
}

.filter-checkbox label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
}

.filter-checkbox input[type="checkbox"] {
  cursor: pointer;
  width: 14px;
  height: 14px;
}

#clear-filters {
  background: none;
  border: 1px solid var(--border);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
  margin-top: 1.1rem;
  transition: background 0.15s;
}

#clear-filters:hover { background: #f0f0f0; }

/* ── Results info ─────────────────────────────────────────────── */
.results-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  display: flex;
  gap: 1rem;
}

/* ── Bill Cards ───────────────────────────────────────────────── */
#results {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.bill-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.1s;
  cursor: pointer;
}

.bill-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.bill-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}

.bill-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-left: auto;
}

.bill-ilga-link {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent-dark);
  text-decoration: none;
  background: var(--chip-bg);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.bill-ilga-link:hover {
  background: var(--chip-hover);
  border-color: var(--accent);
  color: var(--primary);
}

.doc-type {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.doc-type.resolution {
  background: #fef3c7;
  color: #92400e;
}

.bill-number {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-dark);
  background: var(--chip-bg);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
  font-family: monospace;
}

.bill-session {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.bill-status {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.bill-status.pass { background: #d1fae5; color: var(--pass); }
.bill-status.fail { background: #fee2e2; color: var(--fail); }
.bill-status.pending { background: #fef9c3; color: #92400e; }
.bill-status.unknown { background: #f3f4f6; color: var(--text-muted); }

.bill-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
  line-height: 1.35;
}

.bill-description {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.bill-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.2rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.bill-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.bill-meta .label {
  font-weight: 600;
  color: var(--text);
}

.bill-tags {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}

.bill-tag {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: var(--chip-bg);
  color: var(--accent-dark);
}

/* ── Loading / States ─────────────────────────────────────────── */
#loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── Voting Bloc ─────────────────────────────────────────────────── */
.bloc-panel {
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.bloc-panel.loading { text-align: center; }
.bloc-loading { color: var(--text-muted); }
.bloc-error { color: #c44; }

.bloc-inner { display: flex; flex-direction: column; gap: 0.6rem; }

.bloc-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  font-size: 0.78rem;
  font-family: var(--font-mono);
}
.bloc-stats span { color: var(--text-muted); }

.bloc-votes { display: flex; flex-direction: column; gap: 0.25rem; }
.bloc-vote-row { display: flex; align-items: center; gap: 0.5rem; }
.bloc-vote-row .bill-status { font-size: 0.7rem; padding: 1px 5px; }
.bloc-vote-desc { color: var(--text-muted); }

.bloc-section-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.bloc-session {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: 0.1rem;
}

.bloc-outcome {
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
  padding: 0.2rem 0;
}

.bloc-party-cohesion {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin: 0.25rem 0;
}

.bloc-party-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
}

.bloc-loyalty-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  overflow: hidden;
  max-width: 120px;
}
.bloc-loyalty-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}
.bloc-loyalty-pct { font-family: var(--font-mono); font-size: 0.72rem; }

.bloc-rc-detail {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  padding: 1px 0 1px 1rem;
  color: var(--text-muted);
  gap: 0.5rem;
}
.bloc-rc-loyalty.high { color: #e74c3c; font-weight: 600; }
.bloc-rc-loyalty.med { color: #f39c12; }
.bloc-rc-loyalty.low { color: #27ae60; }

.bloc-pair {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.2rem 0;
}
.bill-status-line {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.2rem 0;
  font-size: 0.78rem;
}
.bloc-pair.bipartisan { opacity: 0.75; }
.bloc-pair-sim {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  min-width: 2.5rem;
  color: var(--text-muted);
}
.bloc-pair-names { color: var(--text); }

/* Party color helpers */
.party-d { color: #1a5fb4; font-weight: 500; }
.party-r { color: #c01c28; font-weight: 500; }
.party-x { color: var(--text-muted); }

.bill-card.bloc-active {
  background: var(--bg-card-hover);
  outline: 1px solid var(--border-focus);
}

/* Bloc button */
.bloc-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.bloc-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

@keyframes spin { to { transform: rotate(360deg); } }

#no-results, #error {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

#no-results h3, #error h3 {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 0.5rem;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 600px) {
  .container { padding: 1rem 0.75rem 3rem; }
  .logo h1 { font-size: 1.3rem; }
  .filters { gap: 0.5rem; }
  .bill-header { flex-wrap: wrap; }
}