:root {
  --bg: #1e1f22;
  --card: #2b2d31;
  --text: #f2f3f5;
  --muted: #949ba4;
  --accent: #5865f2;
  --danger: #da373c;
  --border: #3f4147;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.screen { min-height: 100vh; }
.hidden { display: none !important; }

#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  margin: 20px auto;
}

.login-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-logo { max-width: 100%; height: auto; margin-bottom: 12px; }

h1 { font-size: 20px; margin: 0 0 8px; }
h2 { font-size: 16px; margin: 0 0 8px; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; }

input, select {
  width: 100%;
  padding: 8px 10px;
  margin: 6px 0 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #1e1f22;
  color: var(--text);
  font-size: 14px;
}

label { font-size: 12px; color: var(--muted); }

button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
button.secondary { background: #4e5058; }
button.danger { background: var(--danger); }
button:hover { filter: brightness(1.1); }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 10px;
}
.header-logo { height: 40px; width: auto; display: block; }
.header-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.header-right button { padding: 6px 12px; }
.header-right select { width: 220px; margin: 0; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tab-btn {
  background: none;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 12px 16px;
  font-size: 14px;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text); filter: none; }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }

main {
  padding: 20px;
  max-width: 1100px;
  margin: 0 auto;
}
.tab-panel { max-width: none; }

.group-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.group-card .group-info b { display: block; }
.group-targets { font-size: 13px; color: var(--muted); margin-top: 4px; }
.group-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-card {
  background: var(--card);
  border-radius: 10px;
  padding: 20px;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.target-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.target-row select { margin: 0; flex: 1; min-width: 120px; }
.target-row button { padding: 6px 10px; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  margin: 4px 0 12px;
}
.checkbox-row input { width: auto; margin: 0; }

.polls-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.polls-toolbar .checkbox-row { margin: 0; }

.poll-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.poll-card .poll-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}
.poll-card .poll-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: #3f4147;
  color: var(--muted);
  white-space: nowrap;
}
.poll-card .poll-status.open { background: #2d5a3d; color: #7fdb9a; }
.poll-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.poll-option-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 13px;
  flex-wrap: wrap;
}
.poll-option-row .option-label { min-width: 120px; }
.poll-option-row .bar-track {
  flex: 1;
  min-width: 80px;
  background: #1e1f22;
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
}
.poll-option-row .bar-fill { height: 100%; background: var(--accent); }
.poll-option-row .bar-count { width: 110px; color: var(--muted); text-align: right; }
.option-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.option-row input { margin: 0; flex: 1; min-width: 100px; }

/* Team tab's inline add-member row needs its own layout distinct from the modal's
   fixed-width option-row, since it has 4 controls (username, password, role, button). */
#team-tab .option-row {
  align-items: center;
}
#team-tab .option-row select,
#team-tab .option-row input { width: auto; margin: 0; flex: 1 1 140px; }

.role-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: #3f4147;
  color: var(--muted);
  margin-left: 6px;
}
.role-badge.admin { background: #4b3a7a; color: #c9b8ff; }

@media (max-width: 640px) {
  header { padding: 10px 14px; }
  .header-logo { height: 30px; }
  .header-right { width: 100%; justify-content: space-between; }
  .header-right select { width: auto; flex: 1; }
  .tabs { padding: 0 8px; }
  main { padding: 12px; }
  .card { padding: 16px; margin: 12px auto; }
  .modal-card { padding: 16px; }
  .group-card { flex-direction: column; align-items: stretch; }
  .group-actions { width: 100%; }
  .group-actions button { flex: 1; }
  .poll-option-row .bar-count { width: auto; }
}
