:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-400: #94a3b8;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-900: #0f172a;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

/* ── Layout ── */
.app-header {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.app-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}

.app-header .badge {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.main-nav {
  display: flex;
  gap: 2px;
  margin-left: auto;
}

.nav-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--gray-600);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all .15s;
}

.nav-btn:hover { background: var(--gray-100); color: var(--gray-900); }
.nav-btn.active { background: var(--primary-light); color: var(--primary); }

.content {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* ── Cards ── */
.card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: .75rem;
}

.card-header h2 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 1.25rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  border: none;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--gray-600); border: 1px solid var(--gray-200); }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-900); }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th {
  text-align: left;
  padding: 10px 12px;
  background: var(--gray-50);
  color: var(--gray-600);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--gray-200);
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

.actions { display: flex; gap: 4px; justify-content: flex-end; }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.875rem; font-weight: 500; color: var(--gray-700); margin-bottom: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

input[type="text"], input[type="email"], input[type="password"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 7px;
  font-size: 0.9rem;
  color: var(--gray-900);
  background: white;
  transition: border-color .15s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}

.modal-overlay.show { opacity: 1; pointer-events: all; }

.modal {
  background: white;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform .2s;
}

.modal-overlay.show .modal { transform: translateY(0); }

.modal-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--gray-200); display: flex; gap: .5rem; justify-content: flex-end; }
.close-btn { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--gray-400); padding: 2px; }

/* ── Tags / Badges ── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
}

.tag-open { background: var(--success-light); color: var(--success); }
.tag-closed { background: var(--gray-100); color: var(--gray-600); }
.tag-connected { background: var(--success-light); color: var(--success); }
.tag-away { background: var(--gray-100); color: var(--gray-400); }

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 1.5rem;
}

.tab-btn {
  padding: 8px 16px;
  background: none;
  border: none;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .15s;
}

.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Vote UI (participant) ── */
.vote-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--gray-50);
}

.vote-header {
  position: relative;
  background: var(--primary);
  color: white;
  padding: 1rem 1.25rem;
  text-align: center;
}

.vote-header h1 { font-size: 1.1rem; }
.vote-header .session-code { font-size: 1.5rem; font-weight: 700; letter-spacing: .15em; opacity: .9; }

.vote-body { flex: 1; padding: 1.5rem 1rem; max-width: 480px; margin: 0 auto; width: 100%; }

.member-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.member-btn {
  width: 100%;
  padding: 14px 18px;
  background: white;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  text-align: left;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.member-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.member-btn.taken { opacity: .45; cursor: not-allowed; }

.vote-options {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.vote-option-btn {
  width: 100%;
  padding: 16px 20px;
  background: white;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  text-align: center;
}

.vote-option-btn:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.vote-option-btn.pour { border-color: var(--success); }
.vote-option-btn.pour:hover { background: var(--success-light); color: var(--success); }
.vote-option-btn.contre { border-color: var(--danger); }
.vote-option-btn.contre:hover { background: var(--danger-light); color: var(--danger); }

/* ── Results bars ── */
.result-item { margin-bottom: .75rem; }
.result-label { display: flex; justify-content: space-between; font-size: .875rem; font-weight: 500; margin-bottom: 4px; }
.result-bar { height: 8px; background: var(--gray-200); border-radius: 99px; overflow: hidden; }
.result-fill { height: 100%; background: var(--primary); border-radius: 99px; transition: width .5s ease; }
.result-fill.pour { background: var(--success); }
.result-fill.contre { background: var(--danger); }

/* ── Status states ── */
.status-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 2rem 1.25rem;
  text-align: center;
}

.status-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.status-card h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: .5rem; }
.status-card p { color: var(--gray-600); font-size: .9rem; }

/* ── Progress ── */
.progress-bar { height: 6px; background: var(--gray-200); border-radius: 99px; overflow: hidden; margin: .5rem 0; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 99px; transition: width .3s ease; }

/* ── QR Code ── */
.qr-container { text-align: center; padding: 1rem 0; }
.qr-container img { max-width: 200px; border: 4px solid white; border-radius: 8px; box-shadow: var(--shadow-md); }
.qr-url { font-family: monospace; font-size: .8rem; color: var(--gray-600); margin-top: .5rem; word-break: break-all; }

/* ── Empty state ── */
.empty { text-align: center; padding: 2.5rem; color: var(--gray-400); }
.empty .empty-icon { font-size: 2rem; margin-bottom: .5rem; }

/* ── List chips ── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--gray-100);
  font-size: 0.8rem;
  font-weight: 500;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
  .main-nav .nav-btn { padding: 6px 10px; font-size: 0.8rem; }
}

/* ── Alerts ── */
.alert {
  padding: 10px 14px;
  border-radius: 7px;
  font-size: .875rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.alert-success { background: var(--success-light); color: var(--success); }
.alert-danger { background: var(--danger-light); color: var(--danger); }
.alert-info { background: var(--primary-light); color: var(--primary); }

/* ── Section dividers ── */
.section-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-400);
  margin: 1.5rem 0 .75rem;
}

/* ── Spinning loader ── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--gray-900);
  color: white;
  padding: 10px 20px;
  border-radius: 99px;
  font-size: .875rem;
  font-weight: 500;
  z-index: 999;
  transition: transform .3s ease;
  pointer-events: none;
  white-space: nowrap;
}

#toast.show { transform: translateX(-50%) translateY(0); }
