@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;700;800&display=swap');

:root {
  --bg-1: #eef7ff;
  --bg-2: #f7f2ff;
  --card: rgba(255, 255, 255, 0.86);
  --text: #172033;
  --muted: #667085;
  --line: rgba(23, 32, 51, 0.12);
  --primary: #1b4fd8;
  --primary-2: #0f766e;
  --danger: #b42318;
  --success: #067647;
  --shadow: 0 22px 70px rgba(16, 24, 40, 0.14);
  --radius: 28px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Vazirmatn, Tahoma, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 18%, rgba(27, 79, 216, 0.18), transparent 28%),
    radial-gradient(circle at 86% 12%, rgba(15, 118, 110, 0.16), transparent 24%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2));
}

body::before, body::after {
  content: "";
  position: fixed;
  width: 260px;
  height: 260px;
  border-radius: 48px;
  background: rgba(255, 255, 255, 0.35);
  transform: rotate(18deg);
  pointer-events: none;
  z-index: 0;
}

body::before { right: -120px; top: 18%; }
body::after { left: -130px; bottom: 7%; }

.app-shell {
  position: relative;
  z-index: 1;
  width: min(980px, calc(100% - 28px));
  margin: 0 auto;
  padding: 34px 0 24px;
}

.results-shell { width: min(1120px, calc(100% - 28px)); }

.hero-card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  border-radius: var(--radius);
  padding: clamp(22px, 4vw, 42px);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.logo-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  color: white;
  font-weight: 800;
  font-size: 25px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 14px 34px rgba(27, 79, 216, 0.26);
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary-2);
  font-weight: 800;
  letter-spacing: -0.01em;
}

h1, h2 { margin: 0; line-height: 1.25; }
h1 { font-size: clamp(25px, 4vw, 42px); letter-spacing: -0.04em; }
h2 { font-size: 18px; }

.lead {
  max-width: 720px;
  margin: 0 0 26px;
  color: var(--muted);
  line-height: 2;
}

.vote-form { display: grid; gap: 14px; }
.field-label { font-weight: 800; color: #26324b; }
.hint { margin: -4px 0 6px; color: var(--muted); font-size: 13px; line-height: 1.8; }

.input-wrap input {
  width: 100%;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0 18px;
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.92);
  outline: none;
  transition: 0.18s ease;
}

.input-wrap input:focus {
  border-color: rgba(27, 79, 216, 0.55);
  box-shadow: 0 0 0 5px rgba(27, 79, 216, 0.10);
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 6px 12px;
  background: rgba(15, 118, 110, 0.10);
  color: var(--primary-2);
  font-weight: 800;
  font-size: 13px;
  white-space: nowrap;
}

.employee-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 4px;
  max-height: 420px;
  overflow: auto;
  padding: 4px 3px 4px 8px;
}

.employee-option {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  transition: 0.18s ease;
}

.employee-option:hover {
  transform: translateY(-2px);
  border-color: rgba(27, 79, 216, 0.35);
  box-shadow: 0 14px 28px rgba(16, 24, 40, 0.08);
}

.employee-option input { width: 20px; height: 20px; accent-color: var(--primary); }
.employee-option:has(input:checked) {
  border-color: rgba(27, 79, 216, 0.75);
  background: rgba(27, 79, 216, 0.08);
}

.avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: white;
  background: linear-gradient(135deg, #243b8f, #0f766e);
  font-weight: 800;
  flex: 0 0 auto;
}

.employee-name { font-weight: 800; }
.employee-meta { color: var(--muted); font-size: 13px; margin-top: 4px; }

.primary-btn, .ghost-btn {
  border: 0;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  transition: 0.18s ease;
}

.primary-btn {
  margin-top: 12px;
  min-height: 58px;
  border-radius: 20px;
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 18px 34px rgba(27, 79, 216, 0.28);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.primary-btn:hover { transform: translateY(-2px); }
.primary-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-icon { font-size: 20px; transform: translateY(1px); }

.status {
  border-radius: 18px;
  padding: 14px 16px;
  margin: 0 0 18px;
  line-height: 1.8;
  border: 1px solid transparent;
}
.status.success { color: var(--success); background: rgba(6, 118, 71, 0.09); border-color: rgba(6, 118, 71, 0.18); }
.status.error { color: var(--danger); background: rgba(180, 35, 24, 0.08); border-color: rgba(180, 35, 24, 0.16); }
.status.info { color: #1849a9; background: rgba(27, 79, 216, 0.08); border-color: rgba(27, 79, 216, 0.16); }
.hidden { display: none !important; }

.footer-note { text-align: center; margin: 18px 0 0; color: var(--muted); }
.footer-note a { color: var(--primary); font-weight: 800; text-decoration: none; }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 24px 0;
}
.metric {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.72);
}
.metric span { display: block; font-size: 24px; font-weight: 900; }
.metric small { color: var(--muted); }

.winners {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.winner-card {
  border-radius: 24px;
  padding: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
}
.winner-rank { font-weight: 900; color: var(--primary-2); }
.winner-name { font-size: 20px; font-weight: 900; margin: 8px 0; }
.winner-vote { color: var(--muted); }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 10px 0 12px;
}
.ghost-btn {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--primary);
  min-height: 42px;
  padding: 0 16px;
}

.results-table-wrap { overflow-x: auto; }
.results-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 10px;
  min-width: 640px;
}
.results-table th { text-align: right; color: var(--muted); font-size: 13px; padding: 0 14px; }
.results-table td {
  background: rgba(255, 255, 255, 0.78);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 14px;
  font-weight: 700;
}
.results-table td:first-child { border-right: 1px solid var(--line); border-radius: 0 16px 16px 0; }
.results-table td:last-child { border-left: 1px solid var(--line); border-radius: 16px 0 0 16px; }
.bar-cell { min-width: 220px; }
.progress {
  height: 12px;
  background: rgba(27, 79, 216, 0.10);
  border-radius: 999px;
  overflow: hidden;
}
.progress span { display: block; height: 100%; background: linear-gradient(135deg, var(--primary), var(--primary-2)); border-radius: inherit; }

@media (max-width: 760px) {
  .app-shell { width: min(100% - 18px, 980px); padding-top: 14px; }
  .hero-card { border-radius: 22px; padding: 20px; }
  .brand-row { align-items: flex-start; }
  .logo-mark { width: 50px; height: 50px; border-radius: 16px; }
  .employee-list, .metrics-grid, .winners { grid-template-columns: 1fr; }
  .section-head, .toolbar { align-items: stretch; flex-direction: column; }
  .pill { width: fit-content; }
  .lead { font-size: 14px; }
}

.admin-login {
  margin-top: 28px;
  padding: 18px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 22px;
  background: rgba(255,255,255,.08);
}

.admin-login-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.compact-btn {
  min-width: 96px;
  height: 52px;
  padding: 0 22px;
}

.hidden {
  display: none !important;
}

@media (max-width: 640px) {
  .admin-login-row {
    grid-template-columns: 1fr;
  }

  .compact-btn {
    width: 100%;
  }
}

.progress i {
  display: block;
  height: 100%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-radius: inherit;
}

.admin-panel {
  margin-top: 28px;
  padding: 20px;
  border: 1px solid rgba(255, 122, 89, 0.24);
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(255, 122, 89, 0.10), rgba(255, 255, 255, 0.62));
}

.admin-toolbar h2,
.admin-toolbar p {
  margin: 0;
}

.danger-btn {
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, #dc2626, #f97316);
  color: #fff;
  min-height: 46px;
  padding: 0 18px;
  font-weight: 900;
  box-shadow: 0 14px 28px rgba(220, 38, 38, 0.22);
  cursor: pointer;
}

.danger-btn:disabled {
  opacity: .65;
  cursor: not-allowed;
}

.danger-hint {
  color: #8a2c18;
}

.reset-confirm-row {
  margin-top: 18px;
  max-width: 520px;
}

.new-codes-box {
  margin-top: 18px;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .72);
}

.new-codes-box h3 {
  margin: 0;
}

#newCodesText {
  width: 100%;
  min-height: 220px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  resize: vertical;
  direction: ltr;
  text-align: left;
  font-family: Consolas, Monaco, monospace;
  font-size: 13px;
  background: rgba(255,255,255,.9);
}

@media (max-width: 760px) {
  .admin-toolbar {
    gap: 12px;
  }

  .danger-btn {
    width: 100%;
  }
}

.invite-box {
  display: grid;
  gap: 6px;
  margin: 0 0 18px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(27, 79, 216, 0.16);
  background: rgba(27, 79, 216, 0.08);
  color: #1849a9;
  line-height: 1.8;
}

.invite-box strong { font-weight: 900; }
.invite-box span { color: var(--muted); font-size: 13px; }
.invite-box.success {
  color: var(--success);
  background: rgba(6, 118, 71, 0.09);
  border-color: rgba(6, 118, 71, 0.18);
}
.invite-box.error {
  color: var(--danger);
  background: rgba(180, 35, 24, 0.08);
  border-color: rgba(180, 35, 24, 0.16);
}
.invite-box.info {
  color: #1849a9;
  background: rgba(27, 79, 216, 0.08);
  border-color: rgba(27, 79, 216, 0.16);
}

.links-panel {
  border-color: rgba(27, 79, 216, 0.20);
  background: linear-gradient(135deg, rgba(27, 79, 216, 0.08), rgba(255, 255, 255, 0.62));
}

#inviteLinksText {
  width: 100%;
  min-height: 260px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  resize: vertical;
  direction: ltr;
  text-align: left;
  font-family: Consolas, Monaco, monospace;
  font-size: 13px;
  background: rgba(255,255,255,.9);
}
