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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-300: #d1d5db;
  --gray-600: #4b5563;
  --gray-900: #111827;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1);
  --focus-ring: 0 0 0 3px rgba(37,99,235,.15);
  --badge-draft-bg: #f3f4f6;
  --badge-draft-color: #374151;
  --badge-weighing-bg: #fef3c7;
  --badge-weighing-color: #92400e;
  --badge-voting-bg: #dbeafe;
  --badge-voting-color: #1e40af;
  --badge-closed-bg: #fee2e2;
  --badge-closed-color: #b91c1c;
  --success-bg: #dcfce7;
  --success-color: #15803d;
  --alert-bg: #fee2e2;
  --alert-color: #b91c1c;
}

body { font-family: system-ui, sans-serif; color: var(--gray-900); background: var(--gray-50); line-height: 1.6; }

header { background: white; border-bottom: 1px solid var(--gray-300); padding: .75rem 1.5rem; }
header nav { display: flex; align-items: center; justify-content: space-between; max-width: 1100px; margin: 0 auto; }
.logo { font-weight: 700; font-size: 1.25rem; color: var(--primary); text-decoration: none; }
.nav-actions { display: flex; align-items: center; gap: .75rem; }
.nav-user { font-size: .9rem; color: var(--gray-600); }
.btn--sm { padding: .35rem .85rem; font-size: .85rem; }

.auth-section { max-width: 400px; margin: 3rem auto; background: white; padding: 2rem; border-radius: var(--radius); box-shadow: var(--shadow); }
.auth-section h1 { margin-bottom: 1.5rem; }
.auth-form .field { margin-bottom: 1rem; }
.auth-link { margin-top: 1.5rem; text-align: center; font-size: .9rem; color: var(--gray-600); }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.decisions-list { display: flex; flex-direction: column; gap: .75rem; }
.decision-card { display: flex; align-items: center; justify-content: space-between; background: white; border: 1px solid var(--gray-300); border-radius: var(--radius); padding: 1rem 1.25rem; }
.decision-card h3 { margin-bottom: .25rem; }
.decision-card h3 a { color: var(--gray-900); text-decoration: none; }
.decision-card h3 a:hover { color: var(--primary); }
.decision-card small { color: var(--gray-600); font-size: .8rem; }
.empty-state { text-align: center; padding: 3rem; color: var(--gray-600); }

.stage-section { background: white; border: 1px solid var(--gray-300); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.5rem; }
.stage-section h2 { margin-bottom: .75rem; }

.badge--draft    { background: var(--badge-draft-bg); color: var(--badge-draft-color); }
.badge--weighing { background: var(--badge-weighing-bg); color: var(--badge-weighing-color); }
.badge--voting   { background: var(--badge-voting-bg); color: var(--badge-voting-color); }
.badge--closed   { background: var(--badge-closed-bg); color: var(--badge-closed-color); }

main { max-width: 720px; margin: 2rem auto; padding: 0 1rem; }
main.main--wide { max-width: 1100px; }

.flash { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.flash--notice { background: var(--success-bg); color: var(--success-color); }
.flash--alert  { background: var(--alert-bg); color: var(--alert-color); }

.hero { text-align: center; margin-bottom: 2rem; }
.hero h1 { font-size: 2rem; margin-bottom: .5rem; }

.form-section, .setup-header, .voting-header, .result-header,
.invite-section, .participants-section, .info-section, .ranking,
.criteria-breakdown, .weights-section, .scores-section {
  background: white; border: 1px solid var(--gray-300);
  border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

h2 { font-size: 1.25rem; margin-bottom: 1rem; }
h3 { font-size: 1rem; margin-bottom: .75rem; color: var(--gray-600); }

.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: .35rem; }
.field input[type=text],
.field input[type=email],
.field input[type=password],
.field input[type=number],
.field textarea {
  width: 100%; padding: .5rem .75rem; border: 1px solid var(--gray-300);
  border-radius: var(--radius); font-size: 1rem;
}
.field input:focus,
.field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: var(--focus-ring);
}
.field-group { margin-bottom: 1.5rem; }
.nested-field { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.nested-field input { flex: 1; }
.btn--remove { background: none; border: 1px solid var(--gray-300); color: var(--gray-600); padding: .3rem .7rem; font-size: .8rem; border-radius: var(--radius); cursor: pointer; }
.btn--remove:hover { background: var(--alert-bg); border-color: var(--danger); color: var(--danger); }
.comment-section { margin-top: 2rem; }
.comment-section textarea { width: 100%; padding: .6rem .75rem; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: 1rem; resize: vertical; }
.comment-section textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }

.hint { font-size: .85rem; color: var(--gray-600); margin-bottom: .75rem; }
.errors { background: var(--alert-bg); color: var(--alert-color); padding: .75rem; border-radius: var(--radius); margin-bottom: 1rem; }

.btn { display: inline-block; padding: .6rem 1.25rem; border-radius: var(--radius); font-size: 1rem; font-weight: 600; cursor: pointer; border: none; text-decoration: none; }
.btn--primary  { background: var(--primary); color: white; }
.btn--primary:hover { background: var(--primary-dark); }
.btn--secondary { background: var(--gray-100); color: var(--gray-900); }
.btn--danger   { background: var(--danger); color: white; }

.badge { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.badge--open   { background: var(--success-bg); color: var(--success); }
.badge--closed { background: var(--alert-bg); color: var(--danger); }

.copy-box { display: flex; gap: .5rem; margin: .75rem 0; }
.copy-box input { flex: 1; background: var(--gray-100); }
.copy-box button { padding: .5rem 1rem; background: var(--primary); color: white; border: none; border-radius: var(--radius); cursor: pointer; }

.participants-list { list-style: none; margin-bottom: 1rem; }
.participants-list li { display: flex; gap: .75rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--gray-100); font-size: .9rem; flex-wrap: wrap; }
.participants-list small { color: var(--gray-600); font-size: .75rem; flex: 1; }
.status.voted   { color: var(--success); font-weight: 600; }
.status.pending { color: var(--gray-600); }

.action-box { background: var(--gray-50); border: 1px solid var(--gray-300); border-radius: var(--radius); padding: 1rem; margin-top: 1rem; text-align: center; }

.range-row { display: flex; align-items: center; gap: .75rem; }
.range-row input[type=range] { flex: 1; }
.range-value { font-weight: 700; font-size: 1.1rem; min-width: 1.5rem; color: var(--primary); }
.weight-field, .score-field { margin-bottom: .75rem; }
.option-block { background: var(--gray-50); border: 1px solid var(--gray-300); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.option-block h3 { color: var(--gray-900); }

.ranking-item { display: flex; align-items: center; gap: 1rem; padding: 1rem; border-radius: var(--radius); margin-bottom: .75rem; border: 1px solid var(--gray-300); }
.ranking-item--winner { border-color: #fbbf24; background: #fffbeb; }
.rank { font-size: 1.5rem; font-weight: 700; min-width: 2.5rem; text-align: center; }
.option-info { flex: 1; }
.score-bar { width: 140px; height: 10px; background: var(--gray-100); border-radius: 999px; overflow: hidden; }
.score-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s; }
.score-value { font-weight: 700; min-width: 3rem; text-align: right; }

.result-actions { margin-top: 1.5rem; }
.voted-message, .closed-message { background: white; border: 1px solid var(--gray-300); border-radius: var(--radius); padding: 2rem; text-align: center; }

.inline-form { display: flex; gap: .5rem; margin-top: .5rem; }
.inline-form input { flex: 1; padding: .5rem .75rem; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: 1rem; }
.inline-form input:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }
.add-participant-form { border-top: 1px solid var(--gray-100); margin-top: 1rem; padding-top: 1rem; }
.invite-link { color: var(--gray-600); font-size: .75rem; word-break: break-all; }
.simple-list { list-style: none; padding: 0; }
.simple-list li { padding: .35rem 0; border-bottom: 1px solid var(--gray-100); }
.simple-list small { color: var(--gray-600); }
.description { color: var(--gray-600); margin-bottom: .5rem; }
.result-link { margin-top: 1rem; }
.comments-section { margin-top: 2rem; }
.comment-item { background: var(--gray-50); border-left: 3px solid var(--primary); padding: .75rem 1rem; border-radius: 0 var(--radius) var(--radius) 0; margin-bottom: .75rem; }
.comment-item p { margin: .25rem 0 0; color: var(--gray-700); }

/* Admin */
.admin-table-wrap { background: white; border: 1px solid var(--gray-300); border-radius: var(--radius); overflow-x: auto; margin-bottom: 1.5rem; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-table th,
.admin-table td { padding: .75rem 1rem; border-bottom: 1px solid var(--gray-300); }
.admin-table th { background: var(--gray-50); text-align: left; font-weight: 600; white-space: nowrap; }
.admin-table td { padding: .65rem 1rem; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: var(--gray-50); }
.admin-row--self { background: #eff6ff; }
.plan-select { padding: .25rem .5rem; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: .85rem; cursor: pointer; color: var(--gray-600); }
.plan-select--pro  { color: var(--primary); font-weight: 600; }
.inline-select-form { display: inline; }
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
.stat-card { background: white; border: 1px solid var(--gray-300); border-radius: var(--radius); padding: 1.25rem; text-align: center; box-shadow: var(--shadow); }
.stat-number { display: block; font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: .85rem; color: var(--gray-600); }
.badge--plan-free { background: var(--gray-100); }
.badge--plan-pro  { background: #ede9fe; color: #5b21b6; }
