:root {
  --ps-red: #C8102E;
  --ps-red-dark: #9B0C23;
  --ps-red-light: #E8425A;
  --text: #1a1a2e;
  --text-secondary: #555;
  --bg: #f5f6fa;
  --white: #ffffff;
  --border: #e0e0e0;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 20px rgba(0,0,0,0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --transition: all 0.2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: 80px;
}

.portal-header {
  background: linear-gradient(135deg, var(--ps-red) 0%, var(--ps-red-dark) 100%);
  color: var(--white);
  padding: 20px 16px 16px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(200,16,46,0.3);
}

.portal-header h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.portal-header .subtitle {
  font-size: 12px;
  opacity: 0.85;
  margin-top: 2px;
}

.nav-bar {
  display: flex;
  overflow-x: auto;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0;
  gap: 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.nav-bar::-webkit-scrollbar { display: none; }

.nav-item {
  flex: 0 0 auto;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: var(--transition);
  text-align: center;
  user-select: none;
}

.nav-item:hover { color: var(--ps-red); }
.nav-item.active {
  color: var(--ps-red);
  border-bottom-color: var(--ps-red);
}

.page { display: none; padding: 16px; max-width: 800px; margin: 0 auto; }
.page.active { display: block; }

.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  transition: var(--transition);
  border: 1px solid var(--border);
}

.card:hover { box-shadow: var(--shadow-hover); }

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 18px 14px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.stat-number {
  font-size: 32px;
  font-weight: 800;
  color: var(--ps-red);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
  font-weight: 500;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-open { background: #dcfce7; color: #166534; }
.badge-closed { background: #fee2e2; color: #991b1b; }
.badge-upcoming { background: #fef3c7; color: #92400e; }
.badge-tematica { background: #dbeafe; color: #1e40af; }
.badge-setorial { background: #fce7f3; color: #9d174d; }
.badge-global { background: #f3e8ff; color: #6b21a8; }

.motion-card {
  cursor: pointer;
}

.motion-card .motion-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.motion-card .motion-code {
  font-size: 12px;
  color: var(--ps-red);
  font-weight: 700;
}

.motion-card .motion-title {
  font-size: 15px;
  font-weight: 600;
  margin: 4px 0;
}

.motion-card .motion-proposer {
  font-size: 12px;
  color: var(--text-secondary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--ps-red);
  color: var(--white);
}

.btn-primary:hover { background: var(--ps-red-dark); }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: #e8e8e8; }

.btn-sm {
  padding: 8px 16px;
  font-size: 12px;
}

.export-note {
  font-size: 13px;
  color: #666;
  font-style: italic;
}

.btn-full { width: 100%; }

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  transition: var(--transition);
  background: var(--white);
}

.form-input:focus {
  outline: none;
  border-color: var(--ps-red);
  box-shadow: 0 0 0 3px rgba(200,16,46,0.1);
}

.progress-container {
  margin: 16px 0;
}

.progress-bar-bg {
  width: 100%;
  height: 12px;
  background: #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ps-red), var(--ps-red-light));
  border-radius: 6px;
  transition: width 0.5s ease;
}

.progress-text {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.progress-eligible {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #dcfce7;
  color: #166534;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  margin-top: 8px;
}

.supporter-list {
  margin-top: 12px;
}

.supporter-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 14px;
}

.supporter-item:last-child { border-bottom: none; }

.supporter-name { font-weight: 500; }
.supporter-number { color: var(--text-secondary); font-size: 13px; }

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 12px;
}

.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

.section-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--ps-red);
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 12px;
  border: none;
  background: none;
  padding: 0;
}

.agenda-card {
  border-left: 4px solid var(--ps-red);
  padding-left: 16px;
}

.agenda-time {
  font-size: 13px;
  font-weight: 700;
  color: var(--ps-red);
}

.agenda-title {
  font-size: 15px;
  font-weight: 600;
  margin-top: 2px;
}

.agenda-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.doc-card {
  display: flex;
  align-items: center;
  gap: 14px;
}

.doc-icon {
  width: 44px;
  height: 44px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.doc-info { flex: 1; }
.doc-title { font-size: 14px; font-weight: 600; }
.doc-type { font-size: 12px; color: var(--text-secondary); }

.info-section { margin-bottom: 20px; }
.info-section h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--ps-red);
}

.info-section p, .info-section li {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.info-section ul {
  list-style: disc;
  padding-left: 20px;
}

.share-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.qr-container {
  text-align: center;
  margin-top: 16px;
}

.qr-container canvas, .qr-container img {
  max-width: 200px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.results-bar {
  display: flex;
  height: 24px;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}

.results-bar .bar-for { background: #22c55e; }
.results-bar .bar-against { background: #ef4444; }
.results-bar .bar-abstain { background: #f59e0b; }

.results-legend {
  display: flex;
  gap: 16px;
  margin-top: 6px;
  font-size: 12px;
}

.results-legend span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.install-banner {
  background: linear-gradient(135deg, var(--ps-red), var(--ps-red-dark));
  color: var(--white);
  padding: 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  text-align: center;
  display: none;
}

.install-banner h3 { font-size: 15px; margin-bottom: 8px; }
.install-banner p { font-size: 13px; opacity: 0.9; margin-bottom: 12px; }

.detail-section {
  margin-bottom: 16px;
}

.detail-section h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--ps-red);
  margin-bottom: 6px;
}

.detail-section p, .detail-section li {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.detail-section ol, .detail-section ul {
  padding-left: 20px;
}

.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

.tab-btns {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  border: 2px solid var(--border);
  background: var(--white);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
}

.tab-btn.active {
  border-color: var(--ps-red);
  color: var(--ps-red);
  background: rgba(200,16,46,0.05);
}

@media (min-width: 600px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .page { padding: 24px; }
  .portal-header { padding: 24px 16px 20px; }
  .portal-header h1 { font-size: 24px; }
}
