/* ============================================
   Design System — Commune d'Awans Admin
   ============================================ */

:root {
    --primary: #1976D2;
    --primary-light: #e3f2fd;
    --primary-dark: #1565c0;
    --text: #333;
    --text-secondary: #555;
    --text-muted: #888;
    --bg: #f5f7fa;
    --bg-white: #fff;
    --border: #e0e0e0;
    --border-light: #f0f0f0;
    --success: #2e7d32;
    --success-light: #e8f5e9;
    --error: #c62828;
    --error-light: #fce4ec;
    --warning: #f57c00;
    --warning-light: #fff3e0;
    --sidebar-width: 200px;
    --header-height: 56px;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.12);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: inherit; text-decoration: none; cursor: pointer; }
button { cursor: pointer; font: inherit; }
select { cursor: pointer; }
.nav-item, .nav-item * { cursor: pointer !important; }
.status { cursor: default; }
tbody tr:hover { cursor: default; }
input, select, textarea { font: inherit; }

/* ============================================
   Login
   ============================================ */

.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.login-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 40px;
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-logo {
    width: 80px;
    height: auto;
    margin-bottom: 16px;
}

.login-card h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--text);
}

.form-group {
    margin-bottom: 16px;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: var(--bg-white);
    color: var(--text);
    transition: all 0.2s;
}

.form-group select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 32px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
    border-color: var(--text-muted);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.login-error {
    background: var(--error-light);
    color: var(--error);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 12px;
}

.btn-forgot-password {
    display: block;
    margin: 12px auto 0;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: underline;
    padding: 4px 0;
}

.btn-forgot-password:hover {
    color: var(--primary);
}

.forgot-success {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-top: 12px;
    text-align: center;
}

.forgot-success.success {
    background: var(--success-light, #e8f5e9);
    color: var(--success, #2e7d32);
}

.forgot-success.error {
    background: var(--error-light);
    color: var(--error);
}

/* ============================================
   Buttons
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.2s, opacity 0.2s;
}

.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--error); color: #fff; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 20px 20px 12px;
    border-bottom: 1px solid var(--border-light);
    text-align: center;
}

.sidebar-logo {
    width: 120px;
    height: auto;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.nav-section {
    padding: 4px 0;
}

.nav-section-bottom {
    margin-top: auto;
    border-top: 1px solid var(--border-light);
    padding-top: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-left: 3px solid transparent;
    transition: all 0.15s;
}

.nav-item:hover {
    background: var(--bg);
    color: var(--text);
}

.nav-item.active {
    color: var(--primary);
    background: var(--primary-light);
    border-left-color: var(--primary);
    font-weight: 500;
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-badge {
    margin-left: auto;
    background: var(--error);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.sidebar-footer {
    margin-top: auto;
    padding: 12px;
    border-top: 1px solid var(--border-light);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 20px;
    font-size: 0.8rem;
    color: var(--text-muted);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 20px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}

.btn-logout:hover {
    background: var(--error-light);
    color: var(--error);
}

/* ============================================
   Main Content
   ============================================ */

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.content-header {
    position: sticky;
    top: 0;
    height: var(--header-height);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 50;
}

.content-header h1 {
    font-size: 1.1rem;
    font-weight: 600;
}

.header-user {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.page-content {
    padding: 24px;
}

/* ============================================
   Cards & Metrics
   ============================================ */

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.metric-card .metric-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text);
}

.metric-card .metric-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.card-body {
    padding: 20px;
}

/* ============================================
   Tables
   ============================================ */

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    text-align: left;
    padding: 10px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 12px 16px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

tbody td:last-child {
    white-space: nowrap;
}

tbody tr:hover {
    background: var(--bg);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================
   Status badges
   ============================================ */

.status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-active, .status-approved { background: var(--success-light); color: var(--success); }
.status-pending { background: var(--warning-light); color: var(--warning); }
.status-rejected { background: var(--error-light); color: var(--error); }
.status-revoked { background: #f5f5f5; color: #999; }

/* ============================================
   Filters
   ============================================ */

.filters {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filters input,
.filters select {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    background: var(--bg-white);
    color: var(--text);
    transition: all 0.2s;
    height: 36px;
}

.filters select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 32px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.filters input:hover,
.filters select:hover {
    border-color: var(--text-muted);
}

.filters input:focus,
.filters select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* ============================================
   Detail panel (slide-in)
   ============================================ */

.detail-panel {
    position: fixed;
    top: 0;
    right: -480px;
    width: 480px;
    height: 100vh;
    background: var(--bg-white);
    box-shadow: -2px 0 12px rgba(0,0,0,0.1);
    z-index: 200;
    transition: right 0.25s ease;
    display: flex;
    flex-direction: column;
}

.detail-panel.open {
    right: 0;
}

.detail-panel.wide {
    right: -720px;
    width: min(92vw, 720px);
}

.detail-panel.wide.open {
    right: 0;
}

.detail-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.detail-panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.detail-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.detail-panel-actions {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}

.btn-close-panel {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    padding: 4px;
}

.btn-close-panel:hover {
    color: var(--text);
}

/* Detail panel content */
.detail-image {
    margin: -20px -20px 16px -20px;
    overflow: hidden;
}

.detail-image img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.detail-title {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 12px;
    color: var(--text);
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-bottom: 16px;
}

.detail-tag {
    background: var(--primary-light);
    color: var(--primary);
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.detail-tag-muted {
    background: var(--bg);
    color: var(--text-secondary);
}

.detail-date, .detail-source {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.detail-date::before {
    content: '';
}

.detail-source::before {
    content: '·';
    margin-right: 6px;
}

.detail-summary {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    line-height: 1.5;
}

.detail-content {
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text);
}

.detail-content img {
    max-width: 100%;
    border-radius: var(--radius-sm);
}

.detail-link {
    display: inline-block;
    margin-top: 12px;
    margin-right: 12px;
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 500;
}

.detail-link:hover {
    text-decoration: underline;
}

.detail-proposed-by {
    font-size: 0.85rem;
    color: var(--warning);
    background: var(--warning-light);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.detail-field {
    margin-bottom: 12px;
}

.detail-field-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 2px;
}

.detail-field-value {
    font-size: 0.9rem;
    color: var(--text);
}

.detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.2);
    z-index: 199;
    display: none;
}

.detail-overlay.open {
    display: block;
}

/* ============================================
   Result bars (sondages)
   ============================================ */

.result-bar {
    margin-bottom: 8px;
}

.result-bar-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.result-bar-track {
    height: 8px;
    background: var(--border-light);
    border-radius: 4px;
    overflow: hidden;
}

.result-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
}

.result-bar-fill.oui { background: var(--success); }
.result-bar-fill.non { background: var(--error); }
.result-bar-fill.sans-avis { background: var(--text-muted); }

/* ============================================
   Empty state
   ============================================ */

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
}

/* ============================================
   Loading spinner
   ============================================ */

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    gap: 12px;
    color: var(--text-muted);
}

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

/* ============================================
   Toast notifications
   ============================================ */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: #fff;
    box-shadow: var(--shadow-md);
    animation: toast-in 0.25s ease;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--error); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   Notification form
   ============================================ */

.notif-form {
    max-width: 500px;
}

.notif-form .form-group {
    margin-bottom: 16px;
}

.notif-form textarea {
    min-height: 100px;
    resize: vertical;
}

/* ============================================
   Présentation commune (singleton)
   ============================================ */

.commune-info-header {
    margin-bottom: 20px;
}

.commune-info-help {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
    line-height: 1.5;
}

.commune-form {
    max-width: 720px;
}

.commune-form .form-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.commune-form .required {
    color: var(--error);
}

.commune-form textarea {
    resize: vertical;
    font-family: inherit;
    line-height: 1.5;
}

.commune-form .form-group-checkbox label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
}

.commune-form .form-group-checkbox input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.commune-form-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 16px 0;
    font-style: italic;
}

.commune-form .form-actions {
    margin-top: 20px;
}

/* ============================================
   Sondages — builder multi-questions typées
   ============================================ */

.editor-section {
    border-top: 1px solid var(--border-light);
    padding-top: 18px;
    margin-top: 18px;
}
.editor-section:first-of-type {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

.editor-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin: 0 0 14px 0;
}

.editor-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}
.editor-section-header .editor-section-title {
    margin-bottom: 0;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.question-row {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    margin-bottom: 14px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.question-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #fafbfc;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
}

.q-number {
    font-weight: 700;
    font-size: 0.8rem;
    color: #fff;
    background: var(--primary);
    border-radius: 4px;
    padding: 3px 8px;
    letter-spacing: 0.3px;
}

.q-type-select {
    font-size: 0.9rem;
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #fff;
    cursor: pointer;
    flex: 0 0 auto;
}

.required-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: #fff;
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 12px;
    cursor: pointer;
    user-select: none;
}
.required-toggle:has(input:checked) {
    color: var(--primary-dark);
    background: var(--primary-light);
    border-color: var(--primary);
}
.required-toggle input {
    margin: 0;
}

.q-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.btn-icon {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 30px;
    height: 30px;
    font-size: 0.9rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s, color 0.15s;
}
.btn-icon:hover:not(:disabled) {
    background: var(--bg);
    color: var(--text);
}
.btn-icon:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.btn-icon-danger:hover:not(:disabled) {
    background: var(--error-light);
    color: var(--error);
    border-color: var(--error);
}
.btn-icon-subtle {
    border: none;
    background: transparent;
    color: var(--text-muted);
}
.btn-icon-subtle:hover:not(:disabled) {
    background: var(--error-light);
    color: var(--error);
}

.question-body {
    padding: 14px;
}

.q-label-input {
    width: 100%;
    font-size: 1rem;
    font-weight: 500;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 10px;
}
.q-label-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.helper-box {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: 0.82rem;
    line-height: 1.4;
    padding: 9px 12px;
    border-radius: 6px;
    margin-bottom: 12px;
    border-left: 3px solid var(--primary);
}

.helper-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 6px;
    line-height: 1.4;
}

.type-preview {
    background: #fafbfc;
    border: 1px dashed var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    margin-top: 10px;
}
.preview-caption {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 600;
}

.chips-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid var(--border);
    background: #fff;
}
.chip-oui { background: var(--success-light); color: var(--success); border-color: var(--success); }
.chip-non { background: var(--error-light); color: var(--error); border-color: var(--error); }
.chip-sansavis { background: var(--bg); color: var(--text-secondary); }

.open-preview {
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 12px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.scale-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.scale-label-side {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
}
.scale-dots {
    display: flex;
    gap: 6px;
}
.scale-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fff;
    border: 1.5px solid var(--primary);
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 600;
}

.options-block {
    margin-top: 4px;
}
.options-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.option-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.option-mark {
    font-size: 1rem;
    color: var(--text-muted);
    width: 18px;
    text-align: center;
    flex: 0 0 auto;
}
.option-row input[type="text"] {
    flex: 1;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
}
.option-row input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}
.btn-add-option {
    margin-top: 4px;
    width: 100%;
    border-style: dashed;
}

.scale-config .form-grid-2 input {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 100%;
}
.scale-config label {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 4px;
}

.checkbox-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    background: #fff;
    user-select: none;
}
.checkbox-pill:has(input:checked) {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-dark);
}
.checkbox-pill input {
    margin: 0;
}

/* Restriction géographique — autocomplete + chips de rues */
.restriction-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 14px 0 8px 0;
}

.street-autocomplete {
    position: relative;
}
.street-autocomplete input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
}
.street-autocomplete input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.street-autocomplete input:disabled {
    background: var(--bg);
    color: var(--text-muted);
    cursor: wait;
}

.street-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--shadow-md);
    max-height: 280px;
    overflow-y: auto;
    z-index: 10;
}
.street-dropdown.open {
    display: block;
}
.street-dropdown-item {
    padding: 9px 12px;
    font-size: 0.9rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
}
.street-dropdown-item:last-child {
    border-bottom: none;
}
.street-dropdown-item:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
}
.street-dropdown-item mark {
    background: transparent;
    color: var(--primary);
    font-weight: 700;
}
.street-dropdown-empty {
    padding: 10px 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
}

.chips-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
    min-height: 30px;
}
.chips-empty {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-style: italic;
}
.street-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 4px 5px 12px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border: 1px solid var(--primary);
    border-radius: 14px;
    font-size: 0.82rem;
    font-weight: 500;
}
.street-chip-remove {
    background: transparent;
    border: none;
    color: var(--primary-dark);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 0.75rem;
    line-height: 1;
}
.street-chip-remove:hover {
    background: var(--primary);
    color: #fff;
}

/* Stage badges (draft / upcoming / active / closed) */
.stage-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.stage-draft { background: var(--warning-light); color: var(--warning); border: 1px solid var(--warning); }
.stage-upcoming { background: var(--primary-light); color: var(--primary-dark); border: 1px solid var(--primary); }
.stage-active { background: var(--success-light); color: var(--success); border: 1px solid var(--success); }
.stage-closed { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* Full-width dashed "+ Ajouter une question" button — positionné après la dernière question */
.btn-add-question {
    display: block;
    width: 100%;
    padding: 14px;
    margin-top: 4px;
    border: 2px dashed var(--border);
    background: transparent;
    color: var(--primary);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.btn-add-question:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary-dark);
}

/* Button loading state (spinner + disabled) */
.btn-loading {
    pointer-events: none;
    opacity: 0.75;
}
.btn-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
    margin-right: 6px;
    vertical-align: -2px;
}
@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

/* Rue chip (page Rues de la commune) */
.rue-chip {
    display: inline-block;
    padding: 5px 10px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 14px;
    font-size: 0.82rem;
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.rue-chip:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary-dark);
}
.rue-chip-populated {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 500;
}
.rue-chip-count {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 6px;
    vertical-align: 1px;
}

/* ── Street chip count badge (inline avec nom de rue sélectionnée) ── */
.street-chip-count {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 2px;
}

/* ── Modale de restriction territoriale ─────────────────────────── */
body.streets-modal-open { overflow: hidden; }

.streets-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 24px;
    animation: streetsModalFade 120ms ease-out;
}
@keyframes streetsModalFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.streets-modal {
    background: #fff;
    width: min(720px, 100%);
    max-height: min(90vh, 800px);
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.streets-modal-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 18px 20px 14px 20px;
    border-bottom: 1px solid var(--border);
}
.streets-modal-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
}
.streets-modal-subtitle {
    margin: 6px 0 0 0;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.4;
}
.streets-modal-close {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 6px;
    flex-shrink: 0;
}
.streets-modal-close:hover {
    background: var(--bg-soft);
    color: var(--text);
}

.streets-modal-search {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-soft);
}
.streets-modal-search input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    background: #fff;
}
.streets-modal-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.streets-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.streets-modal-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
}

.streets-modal-section {
    border-bottom: 1px solid var(--border);
}
.streets-modal-section:last-child { border-bottom: none; }

.streets-modal-section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--bg-soft);
}
.streets-modal-toggle {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    padding: 4px 0;
    color: var(--text);
    font-size: 0.95rem;
}
.streets-modal-toggle:hover { color: var(--primary); }
.streets-modal-chevron {
    display: inline-block;
    transition: transform 150ms ease-out;
    color: var(--text-muted);
    font-size: 0.8rem;
}
.streets-modal-section.open .streets-modal-chevron { transform: rotate(90deg); }

.streets-modal-section-meta {
    margin-left: auto;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 400;
    padding-right: 8px;
}

.streets-modal-entity-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    padding: 4px 8px;
    border-radius: 6px;
    background: #fff;
    border: 1px solid var(--border);
}
.streets-modal-entity-toggle:hover { border-color: var(--primary); color: var(--primary); }
.streets-modal-entity-toggle input {
    margin: 0;
    accent-color: var(--primary);
    cursor: pointer;
}

.streets-modal-list {
    list-style: none;
    margin: 0;
    padding: 4px 0;
    background: #fff;
}
.streets-modal-item {
    padding: 0;
    transition: background-color 100ms ease-out;
}
.streets-modal-item:hover { background: var(--bg-soft); }
.streets-modal-item.checked { background: var(--primary-light); }
.streets-modal-item label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 20px 8px 44px;
    cursor: pointer;
    user-select: none;
}
.streets-modal-item input[type="checkbox"] {
    accent-color: var(--primary);
    cursor: pointer;
    width: 16px;
    height: 16px;
    margin: 0;
}
.streets-modal-item-name {
    flex: 1;
    font-size: 0.88rem;
    color: var(--text);
}
.streets-modal-item-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--border);
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 28px;
    text-align: center;
}
.streets-modal-item.checked .streets-modal-item-count {
    background: var(--primary);
    color: #fff;
}

.streets-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-soft);
    flex-wrap: wrap;
}
.streets-modal-totals {
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.streets-modal-actions {
    display: flex;
    gap: 8px;
}

@media (max-width: 640px) {
    .streets-modal-overlay { padding: 0; }
    .streets-modal {
        max-height: 100vh;
        border-radius: 0;
        width: 100%;
    }
    .streets-modal-header { padding: 14px 16px 10px 16px; }
    .streets-modal-search { padding: 10px 16px; }
    .streets-modal-section-header { padding: 10px 16px; }
    .streets-modal-item label { padding: 8px 16px 8px 36px; }
    .streets-modal-footer { padding: 12px 16px; }
    .streets-modal-section-meta { display: block; width: 100%; margin-left: 24px; padding-right: 0; }
}
