:root {
  --bg: #f4f7fb;
  --text: #0f172a;
  --muted: #475569;
  --line: #d7dfec;
  --card: #ffffff;
  --brand: #4338ca;
  --brand2: #ec4899;
  --accent: #06b6d4;
  --success: #047857;
  --danger: #dc2626;
  --shadow: 0 18px 42px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  direction: rtl;
  color: var(--text);
  font-family: "Heebo", "Assistant", sans-serif;
  background:
    radial-gradient(circle at 8% -8%, #ddd6fe 0%, transparent 32%),
    radial-gradient(circle at 94% -4%, #fbcfe8 0%, transparent 28%),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 46%, #f1f5f9 100%);
}

.container { width: min(1260px, 94%); margin: 0 auto; }
.site-title-strip {
  background: linear-gradient(90deg, #312e81, #7c3aed, #db2777);
  color: #fff;
  text-align: center;
  padding: 9px 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 22px rgba(67, 56, 202, 0.25);
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 200;
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  padding: 10px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-wrap { display: flex; gap: 10px; align-items: center; }
.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  color: white;
  font-weight: 800;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand2));
}
.brand-logo-img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 6px 12px rgba(15, 23, 42, 0.16));
}
.brand { font-weight: 800; font-size: 1.06rem; }
.brand-sub { color: var(--muted); font-size: 0.85rem; }

.nav { display: flex; gap: 8px; flex-wrap: wrap; }
.nav a {
  text-decoration: none;
  color: #1e293b;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 0.91rem;
}
.nav a:hover { color: var(--brand); border-color: #a5b4fc; }

.hero {
  margin: 20px 0 16px;
  border-radius: 24px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
  background: var(--card);
}
.hero-media {
  width: 100%;
  height: auto;
  display: block;
  background: #e2e8f0;
}
.hero-content {
  padding: 26px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), #ffffff 55%);
}
.hero h1 { margin: 0 0 8px; font-size: clamp(1.55rem, 3vw, 2.4rem); }
.hero p { margin: 0; color: var(--muted); }

.promo-banner {
  margin-top: 14px;
  border: 1px solid #fcd34d;
  background: linear-gradient(90deg, #fef3c7, #fde68a);
  color: #78350f;
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 700;
}
.promo-banner-rich {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 12px;
  align-items: center;
  border: 1px solid #f5d56c;
  border-radius: 14px;
  background: linear-gradient(120deg, #fff8dc 0%, #ffefb0 100%);
  padding: 10px;
}
.promo-banner-rich img {
  width: 100%;
  border-radius: 10px;
  border: 1px solid #f4d260;
  object-fit: cover;
}
.promo-banner-rich p {
  margin: 0;
  color: #78350f;
  font-size: 1rem;
  line-height: 1.45;
  font-weight: 700;
}

.section-title { margin: 24px 0 12px; font-size: 1.28rem; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid-candidates { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.card {
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--card);
  padding: 14px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}
.poll-card-cover {
  width: 100%;
  height: 180px;
  object-fit: cover;
  object-position: center;
  background: #eef2ff;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  margin-bottom: 10px;
}
.poll-card h3 { margin: 0 0 8px; font-size: 1.1rem; }
.muted { color: var(--muted); }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.btn {
  border: none;
  border-radius: 11px;
  padding: 10px 14px;
  color: white;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  background: linear-gradient(90deg, var(--brand), #6366f1);
  font-weight: 700;
}
.btn.secondary { background: linear-gradient(90deg, var(--brand2), #8b5cf6); }
.btn.ghost { color: #1f2937; background: white; border: 1px solid var(--line); }
.btn.danger { background: linear-gradient(90deg, #dc2626, #f43f5e); }

.form-group { margin-bottom: 12px; }
label { display: block; margin-bottom: 6px; font-weight: 600; }
input, textarea, select {
  width: 100%;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: white;
  padding: 10px 12px;
  color: var(--text);
  font-family: inherit;
}
textarea { min-height: 92px; resize: vertical; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.candidate-option {
  border: 1px solid #dbe5f2;
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  background: linear-gradient(180deg, #f8fbff, #f3f7ff);
  transition: 0.2s ease;
}
.candidate-option:hover { transform: translateY(-2px); box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08); }
.candidate-option.active { border-color: #4f46e5; box-shadow: 0 0 0 2px #c7d2fe; }
.candidate-option img {
  width: 100%;
  aspect-ratio: 4 / 4.6;
  object-fit: contain;
  background: linear-gradient(180deg, #f8fbff 0%, #eef2ff 100%);
  display: block;
}
.candidate-option .body { padding: 10px; }
.candidate-option h4 { margin: 0 0 4px; }

.result-row {
  display: grid;
  grid-template-columns: 62px 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #edf2f7;
}
.result-row img {
  width: 62px;
  height: 62px;
  border-radius: 10px;
  object-fit: contain;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.poll-progress {
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  background: #e2e8f0;
}
.poll-progress > span { height: 100%; display: block; background: linear-gradient(90deg, var(--brand), var(--accent)); }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: right; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f8fafc; }
.success-text { color: var(--success); }
.danger-text { color: var(--danger); }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-12 { margin-bottom: 12px; }

@media (max-width: 760px) {
  .topbar-inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .brand-wrap {
    justify-content: flex-start;
    min-width: 0;
  }
  .brand-wrap > div {
    min-width: 0;
  }
  .brand {
    font-size: 0.96rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 52vw;
  }
  .brand-sub { display: none; }

  .nav {
    position: fixed;
    top: calc(70px + env(safe-area-inset-top));
    right: 12px;
    left: 12px;
    z-index: 180;
    display: none;
    width: auto;
    max-height: calc(100dvh - 92px - env(safe-area-inset-top));
    overflow: auto;
    padding: 12px;
    border-radius: 18px;
    background: #ffffff;
    border: 1px solid #d4deef;
    box-shadow: 0 18px 38px rgba(15, 23, 42, 0.28);
    backdrop-filter: none;
    grid-template-columns: 1fr;
    gap: 10px;
    pointer-events: auto;
  }
  .nav.mobile-open {
    display: grid;
  }
  .nav a {
    text-align: right;
    padding: 12px 10px;
    font-size: 0.95rem;
    border-radius: 14px;
    border: 1px solid #d7e3f5;
    background: linear-gradient(180deg, #ffffff, #f4f8ff);
    font-weight: 700;
    line-height: 1.3;
    color: #1e293b;
    display: block;
  }

  .mobile-menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #cfdbef;
    background: linear-gradient(180deg, #ffffff, #f3f7ff);
    color: #1e3a8a;
    border-radius: 12px;
    padding: 10px 12px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 10px 18px rgba(30, 64, 175, 0.12);
  }
  .mobile-menu-toggle .bars {
    display: inline-flex;
    flex-direction: column;
    gap: 3px;
  }
  .mobile-menu-toggle .bars span {
    width: 16px;
    height: 2px;
    border-radius: 999px;
    background: #1d4ed8;
  }
  .mobile-menu-toggle.is-open .bars span:nth-child(2) {
    opacity: 0;
  }
  .mobile-menu-toggle.is-open .bars span:nth-child(1) {
    transform: translateY(5px) rotate(45deg);
  }
  .mobile-menu-toggle.is-open .bars span:nth-child(3) {
    transform: translateY(-5px) rotate(-45deg);
  }

  .mobile-nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 170;
    display: none;
    pointer-events: auto;
  }
  .mobile-nav-overlay.open {
    display: block;
  }

  .row { flex-direction: column; }
  .hero-media { height: auto; }
  .promo-banner-rich {
    flex-direction: column;
    text-align: center;
    padding: 20px 16px;
  }
  
  .promo-banner-rich img {
    width: 100%;
    max-width: 240px;
  }
  
  .promo-banner-rich p {
    font-size: 1.1rem;
  }

  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* Professional portal redesign overrides */
:root {
  --bg: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --card: #ffffff;
  --brand: #4f46e5;
  --brand2: #ec4899;
  --accent: #06b6d4;
  --success: #10b981;
  --danger: #ef4444;
  --portal-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --hover-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

body {
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.site-title-strip {
  background: linear-gradient(90deg, #1e1b4b, #4f46e5, #be185d);
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.topbar {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.brand {
  font-size: 1.2rem;
  color: #1e1b4b;
  font-weight: 800;
}

.brand-sub {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.nav a {
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 8px 16px;
  font-weight: 600;
  background: transparent;
  color: var(--text);
  transition: all 0.3s ease;
}

.nav a:hover {
  background: #f1f5f9;
  color: var(--brand);
  border-color: #cbd5e1;
}

.hero {
  border-radius: 24px;
  border: none;
  box-shadow: var(--portal-shadow);
  overflow: hidden;
  margin-top: 32px;
}

.hero-content {
  padding: 40px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), #ffffff);
  text-align: center;
}

.hero h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 800;
  color: #1e293b;
  margin-bottom: 16px;
}

.hero p {
  font-size: 1.1rem;
  color: var(--muted);
  max-width: 800px;
  margin: 0 auto;
}

.card {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--card-shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  background: var(--card);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--hover-shadow);
}

.poll-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.poll-card-cover {
  border-radius: 16px;
  border: none;
  margin-bottom: 16px;
  aspect-ratio: 16 / 9;
  width: 100%;
  object-fit: cover;
}

.poll-card h3 {
  font-size: 1.25rem;
  color: #0f172a;
  margin-bottom: 12px;
  font-weight: 700;
}

.poll-card p.muted {
  flex-grow: 1;
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Image Normalization */
.image-container {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 16px;
  background: #f1f5f9;
  position: relative;
}

.image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.candidate-option:hover .image-container img {
  transform: scale(1.05);
}

.section-title {
  color: #0f172a;
  margin-top: 48px;
  margin-bottom: 24px;
  font-size: 1.75rem;
  font-weight: 800;
  text-align: center;
}

.btn {
  border-radius: 12px;
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--brand), #6366f1);
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
  transition: all 0.3s ease;
  font-size: 1rem;
  text-align: center;
  border: none;
  color: white;
  font-weight: 700;
  cursor: pointer;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
}

.btn.secondary {
  background: linear-gradient(135deg, var(--brand2), #f43f5e);
  box-shadow: 0 4px 14px rgba(236, 72, 153, 0.3);
}

.btn.secondary:hover {
  box-shadow: 0 6px 20px rgba(236, 72, 153, 0.4);
}

.btn.ghost {
  background: transparent;
  border: 2px solid var(--line);
  color: var(--text);
  box-shadow: none;
}

.btn.ghost:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: #f8fafc;
}

.btn.danger {
  background: linear-gradient(135deg, var(--danger), #f87171);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

.pill {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #475569;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
}

input, textarea, select {
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  padding: 12px 16px;
  font-size: 1rem;
  transition: all 0.3s ease;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.candidate-option {
  border-radius: 20px;
  border: 2px solid transparent;
  background: var(--card);
  box-shadow: var(--card-shadow);
  transition: all 0.3s ease;
  padding: 12px;
}

.candidate-option:hover {
  transform: translateY(-4px);
  box-shadow: var(--hover-shadow);
  border-color: #e2e8f0;
}

.candidate-option.active {
  border-color: var(--brand);
  background: #f8fafc;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.candidate-option .body {
  padding: 16px 8px 8px;
  text-align: center;
}

.candidate-option .body h4 {
  color: #0f172a;
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}

.promo-banner-rich {
  border-radius: 20px;
  border: 1px solid #fde047;
  background: linear-gradient(135deg, #fffbeb 0%, #fef08a 100%);
  box-shadow: 0 10px 25px -5px rgba(234, 179, 8, 0.25);
  padding: 24px;
  margin-top: 32px;
  gap: 24px;
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.promo-banner-rich::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #eab308, #f59e0b, #eab308);
}

.promo-banner-rich img {
  border-radius: 16px;
  border: 2px solid #ffffff;
  box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.15);
  width: 140px;
  height: auto;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.promo-banner-rich:hover img {
  transform: scale(1.05) rotate(-2deg);
}

.promo-banner-rich p {
  font-size: 1.25rem;
  color: #713f12;
  font-weight: 800;
  line-height: 1.5;
  margin: 0;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

table {
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  background: white;
}

th {
  background: #f8fafc;
  color: #334155;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  padding: 16px;
}

td {
  padding: 16px;
  color: #475569;
}

/* Vote success modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 120;
  padding: 24px;
}

.modal-overlay.open {
  display: flex;
}

.modal-card {
  width: min(600px, 100%);
  background: #ffffff;
  border-radius: 24px;
  border: none;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  padding: 32px;
  position: relative;
  animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from { transform: translateY(20px) scale(0.95); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-close-btn {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #f1f5f9;
  color: #64748b;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: grid;
  place-items: center;
}

.modal-close-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.modal-badge {
  display: inline-block;
  background: #d1fae5;
  color: #047857;
  border: none;
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.modal-card h3 {
  margin: 0 0 12px;
  font-size: 1.75rem;
  color: #0f172a;
  font-weight: 800;
}

.modal-card p {
  margin: 0;
  color: #475569;
  line-height: 1.6;
  font-size: 1.05rem;
}

.modal-actions {
  margin-top: 32px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.whatsapp-btn {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.whatsapp-btn:hover {
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.selection-status {
  border: 2px solid #e0e7ff;
  background: #f0fdfa;
  color: #047857;
  border-radius: 16px;
  padding: 16px 24px;
  font-size: 1.1rem;
  font-weight: 700;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.selection-status.is-complete {
  border-color: #34d399;
  background: #ecfdf5;
  color: #065f46;
}

.selection-status-floating {
  position: fixed;
  top: calc(85px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(1260px, 94%);
  z-index: 150;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

.vote-page main.container {
  padding-top: 90px;
}

@media (max-width: 760px) {
  .hero-content {
    padding: 24px 16px;
  }

  .hero h1 {
    font-size: 1.75rem;
  }

  .card {
    border-radius: 16px;
    padding: 16px;
  }

  .btn {
    width: 100%;
    padding: 14px;
    font-size: 1.05rem;
  }

  .modal-actions .btn {
    width: 100%;
  }

  .selection-status {
    position: static;
    top: auto;
    z-index: auto;
    font-size: 1rem;
    padding: 12px 16px;
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }

  .selection-status-floating {
    position: fixed;
    top: calc(70px + env(safe-area-inset-top));
    width: calc(100% - 24px);
    left: 12px;
    transform: none;
    z-index: 185;
  }

  .vote-page main.container {
    padding-top: 100px;
  }
  
  .grid-2, .grid-3, .grid-candidates {
    grid-template-columns: 1fr;
  }
  
  .candidate-option {
    display: flex;
    align-items: center;
    padding: 12px;
    gap: 16px;
  }
  
  .candidate-option .image-container {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    border-radius: 12px;
  }
  
  .candidate-option .body {
    padding: 0;
    text-align: right;
    flex-grow: 1;
  }
}
