/* ======================== */
/*  LAYOUT                    */
/* ======================== */
.app {
  display: flex;
  min-height: 100vh;
  background: var(--bg-page);
}

/* ======================== */
/*  SIDEBAR                   */
/* ======================== */
.sidebar {
  width: 260px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  z-index: 20;
  transition: transform 0.3s ease;
}
.sidebar-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-brand {
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
}
.sidebar-close {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
}
.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  border-radius: 0.625rem;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.nav-item:hover {
  background: var(--primary-50);
  color: var(--primary);
}
.nav-item.active {
  background: var(--primary-50);
  color: var(--primary);
  font-weight: 600;
}
.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}
.logout-btn:hover {
  background: rgba(220, 38, 38, 0.1) !important;
  color: #dc2626 !important;
}

/* ======================== */
/*  MAIN                      */
/* ======================== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.main-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
}
.main-header-title {
  font-size: 1.125rem;
  font-weight: 600;
  flex: 1;
  margin: 0;
}
.main-header-user {
  font-size: 0.875rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.burger {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.burger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
}

.main-content {
  padding: 2rem;
  flex: 1;
  max-width: 56rem;
  margin: 0 auto;
  width: 100%;
}

/* ======================== */
/*  DASHBOARD CARDS           */
/* ======================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.5rem;
}
.stat-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
}

.action-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.action-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.75rem;
  text-align: center;
  cursor: pointer;
  transition: box-shadow 0.25s, transform 0.25s;
}
.action-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}
.action-card-icon {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 0.75rem;
  background: var(--primary-50);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
}
.action-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.action-card p {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0;
}

/* ======================== */
/*  POLLS LIST                */
/* ======================== */
.poll-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.25rem 1.5rem;
  margin-bottom: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: box-shadow 0.2s;
}
.poll-item:hover { box-shadow: var(--shadow-sm); }
.poll-info { min-width: 0; }
.poll-title { font-weight: 600; font-size: 0.9375rem; margin-bottom: 0.25rem; color: var(--text); }
.poll-meta { font-size: 0.8125rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.375rem; flex-wrap: wrap; }
.poll-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.poll-actions .btn {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  border-radius: 0.5rem;
}
.badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-active { background: #dcfce7; color: #166534; }
.badge-closed { background: var(--primary-50); color: var(--text-muted); }

/* ======================== */
/*  PROFILE                   */
/* ======================== */
.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 2rem;
  max-width: 32rem;
}
.profile-avatar {
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  background: var(--primary-50);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
}
.profile-row {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9375rem;
}
.profile-row:last-child { border: none; }
.profile-label { color: var(--text-muted); }
.profile-value { font-weight: 500; }

/* ======================== */
/*  MODAL                     */
/* ======================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal {
  background: var(--bg-card);
  border-radius: 1rem;
  width: 100%;
  max-width: 32rem;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.modal-header h3 { font-size: 1.25rem; font-weight: 700; margin: 0; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.25rem;
}
.option-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.625rem;
  align-items: center;
}
.option-row input { flex: 1; min-width: 0; }
.remove-option {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 0.5rem;
  width: 2.25rem;
  height: 2.25rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.125rem;
  color: var(--text-muted);
  transition: all 0.15s;
}
.remove-option:hover { color: #dc2626; border-color: #fecaca; background: rgba(220, 38, 38, 0.08); }
.btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.25rem 0;
  font-family: inherit;
}
.btn-text:hover { text-decoration: underline; }

/* Share */
.share-preview-text {
  background: var(--primary-50);
  border: 1px solid var(--primary-100);
  border-radius: 0.75rem;
  padding: 1rem;
  font-size: 0.9375rem;
  line-height: 1.6;
  margin-bottom: 1.25rem;
  color: var(--text);
}
.copy-row { display: flex; gap: 0.5rem; }
.copy-row input { flex: 1; }
.copy-row .btn { flex-shrink: 0; }
.qr-block {
  text-align: center;
  margin-top: 1.25rem;
}
.qr-block img {
  max-width: 200px;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
}

/* Empty */
.empty-state {
  background: var(--bg-card);
  border: 1.5px dashed var(--border);
  border-radius: 0.75rem;
  padding: 2.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

/* field-row */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* date input */
input[type="date"] {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  font-family: inherit;
  border: 1.5px solid var(--border);
  border-radius: 0.75rem;
  background: var(--bg-card);
  color: var(--text);
  color-scheme: light;
  transition: border-color 0.2s, box-shadow 0.2s;
}
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="datetime-local"] {
  color-scheme: dark;
}
input[type="date"]:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

/* datetime-local, select */
input[type="datetime-local"],
select {
  width: 100%;
  padding: 0.625rem 1rem;
  font-size: 0.9375rem;
  font-family: inherit;
  border: 1.5px solid var(--border);
  border-radius: 0.75rem;
  background: var(--bg-card);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  -webkit-appearance: none;
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
select option {
  background: var(--bg-card);
  color: var(--text);
}
input[type="datetime-local"]:focus,
select:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.modal-settings {
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.875rem 1rem;
  margin-bottom: 1rem;
}
.modal-settings .auth-checkbox {
  margin-bottom: 0.5rem;
}
.modal-settings .auth-checkbox:last-child {
  margin-bottom: 0;
}

/* ======================== */
/*  WIZARD                    */
/* ======================== */
.wizard {
  max-width: 40rem;
}
.wizard-progress {
  height: 4px;
  background: var(--primary-50);
  border-radius: 2px;
  margin-bottom: 2rem;
  overflow: hidden;
}
.wizard-progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.4s ease;
}
.wizard-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}
.wizard-sub {
  color: var(--text-muted);
  font-size: 0.9375rem;
  margin-bottom: 1.5rem;
}
.wizard-btns {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem;
  gap: 1rem;
}
.crit-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  align-items: center;
}
.crit-row .w-crit-name { flex: 1; }
.crit-weight-wrap {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}
.crit-weight-wrap input {
  width: 5rem;
  text-align: center;
}
.crit-pct {
  font-size: 0.875rem;
  color: var(--text-muted);
}
.weight-total {
  font-size: 0.875rem;
  font-weight: 600;
}

/* Score table */
.score-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.score-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.score-table th {
  text-align: center;
  padding: 0.625rem 0.5rem;
  background: var(--primary-50);
  font-weight: 600;
  font-size: 0.8125rem;
  white-space: nowrap;
}
.score-table td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.score-alt-name {
  font-weight: 600;
  white-space: nowrap;
  padding-right: 1rem !important;
}
.score-input {
  width: 4rem;
  text-align: center;
  padding: 0.375rem !important;
  font-size: 0.875rem;
}
.th-w {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Result winner */
.result-winner {
  background: var(--hero-gradient);
  border-radius: 1rem;
  padding: 2rem;
  text-align: center;
  color: #fff;
  margin-bottom: 2rem;
}
.winner-label {
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.8;
  margin-bottom: 0.5rem;
}
.winner-name {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
}
.winner-score {
  font-size: 1.125rem;
  opacity: 0.9;
}

/* Result bars */
.result-row { margin-bottom: 1rem; }
.result-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.375rem;
  font-size: 0.9375rem;
}
.result-text { font-weight: 500; }
.result-pct { color: var(--primary); font-weight: 600; }
.result-bar-bg {
  height: 0.5rem;
  background: var(--primary-50);
  border-radius: 0.25rem;
  overflow: hidden;
}
.result-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 0.25rem;
  transition: width 0.6s ease;
}

/* ======================== */
/*  RESPONSIVE                */
/* ======================== */
/* Mobile overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 19;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .burger { display: flex; }
  .main-content { padding: 1.25rem; }
  .field-row { grid-template-columns: 1fr; }
  .poll-actions { flex-wrap: wrap; }
}
