:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --card: #243247;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #f59e0b;
  --accent-dim: #d97706;
  --ok: #10b981;
  --border: #334155;
  --danger: #f87171;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* --- Thème clair --- */
html[data-theme="light"] {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --card: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #d97706;
  --accent-dim: #b45309;
  --ok: #059669;
  --border: #cbd5e1;
  --danger: #dc2626;
}

html[data-theme="light"] .log-pre {
  background: #e2e8f0;
  color: #1e293b;
}

html[data-theme="light"] .bon-papier-numero {
  color: #1e293b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex-shrink: 0;
}

/* Ampoule « idée » — admins, en haut à gauche */
.idea-bulb-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.15rem 0.35rem 0.05rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(250, 204, 21, 0.2) 0%, transparent 100%);
  cursor: pointer;
  flex-shrink: 0;
  animation: idea-bulb-pulse 2.8s ease-in-out infinite;
}
.idea-bulb-btn:hover {
  background: linear-gradient(180deg, rgba(250, 204, 21, 0.45) 0%, rgba(250, 204, 21, 0.08) 100%);
  transform: scale(1.05);
}
.idea-bulb-btn:active {
  transform: scale(0.98);
}
.idea-bulb-svg {
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
}
.idea-bulb-label {
  font-size: 0.62rem;
  font-weight: 700;
  color: #facc15;
  letter-spacing: 0.02em;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
@keyframes idea-bulb-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.12); }
}
html[data-theme="light"] .idea-bulb-label {
  color: #ca8a04;
  text-shadow: none;
}
html[data-theme="light"] .idea-bulb-btn {
  background: linear-gradient(180deg, rgba(250, 204, 21, 0.35) 0%, transparent 100%);
}

.brand {
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.topbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.85rem 1rem;
  min-width: 0;
  flex: 1;
}

.topbar-user {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
  max-width: min(220px, 42vw);
  text-align: right;
}

.topbar-user-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.topbar-user-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-user-email {
  font-size: 0.72rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

.nav a:hover {
  color: var(--text);
  background: var(--card);
}

.btn-nav {
  background: var(--accent);
  color: var(--bg) !important;
  font-weight: 600;
}

.logout {
  color: var(--danger) !important;
}

.main {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}

.footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.75rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 0.75rem;
}

h2 {
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.page-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.paper-hint {
  margin-bottom: 0.75rem;
}

.subcard {
  background: var(--surface);
  margin-bottom: 1.25rem;
  padding: 1rem;
  border-radius: 10px;
  border: 1px dashed var(--border);
}

.h2-inline {
  font-size: 1rem;
  margin: 0 0 0.35rem;
}

.bon-chantier {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

.bon-materiel {
  display: block;
  font-size: 0.8rem;
  color: var(--text, inherit);
  margin-top: 0.2rem;
  line-height: 1.35;
}

.bon-materiel-label {
  color: var(--muted);
  font-weight: 500;
  margin-right: 0.35rem;
}

.materiel-rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.35rem 0 0.65rem;
}

.materiel-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.materiel-row input {
  flex: 1;
  min-width: 0;
}

.btn-mat-remove {
  flex-shrink: 0;
  padding: 0.4rem 0.55rem;
  min-width: 2.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--danger);
}

.btn-mat-remove:hover {
  border-color: var(--danger);
}

.materiel-list-read {
  margin: 0;
  padding-left: 1.1rem;
}

.materiel-block .materiel-add-btn {
  margin-top: 0.25rem;
  font-size: 0.9rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card.narrow,
.login-card {
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.card.mini {
  margin-bottom: 0.5rem;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.empty {
  padding: 2rem;
  text-align: center;
}

.form label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.form input,
.form textarea,
.form select {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}

.form input:focus,
.form textarea:focus,
.form select:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

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

.row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

@media (max-width: 520px) {
  .row-3 {
    grid-template-columns: 1fr;
  }
}

.btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.btn.primary {
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

.btn.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.wide {
  width: 100%;
}

.alert {
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.alert-error {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.alert-ok {
  background: rgba(16, 185, 129, 0.15);
  color: var(--ok);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 0.75rem;
}

.role-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
}

.role-box h3 {
  font-size: 0.95rem;
  margin: 0 0 0.5rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.role-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

.section-title {
  font-size: 1.15rem;
  margin: 1.5rem 0 0.35rem;
}

.user-editor-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.user-editor-head h3 {
  font-size: 1rem;
  margin: 0;
  flex: 1;
  min-width: 12rem;
}

.form-compact label {
  margin-bottom: 0.5rem;
}

.pass-row {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
}

.badge-draft {
  background: #92400e;
  border-color: #f59e0b;
  color: #fbbf24;
  text-decoration: none;
  font-size: 0.72rem;
}
.badge-draft:hover { background: #78350f; }

.chantier-bon-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.status-draft {
  border-color: var(--muted);
  color: var(--muted);
}

.status-submitted {
  border-color: var(--accent);
  color: var(--accent);
}

.status-validated {
  border-color: var(--ok);
  color: var(--ok);
}

.bon-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.bon-list li {
  margin-bottom: 0.5rem;
}

.bon-card {
  display: block;
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
}

.bon-card:hover {
  border-color: var(--accent);
}

.bon-card:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.35);
}

.bon-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.bon-date {
  font-weight: 600;
}

.bon-numero {
  color: var(--accent);
  font-family: "Consolas", "Monaco", monospace;
  letter-spacing: 0.03em;
}

.bon-papier-numero {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0.5rem 0;
  color: #1e293b;
}

.bon-worker {
  display: block;
  font-size: 0.9rem;
  color: var(--accent);
  margin-bottom: 0.15rem;
}

.bon-client {
  display: block;
  font-size: 0.9rem;
  color: var(--accent);
}

.bon-desc {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.bon-photos {
  font-size: 0.75rem;
  color: var(--muted);
}

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1rem;
  margin: 0;
}

.kv dt {
  margin: 0;
  color: var(--muted);
  font-weight: normal;
}

.kv dd {
  margin: 0;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.photo-grid figure {
  margin: 0;
}

.photo-grid img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.photo-grid figcaption {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.upload-form {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.inline-form {
  display: inline-block;
  margin-right: 0.5rem;
  margin-bottom: 0.5rem;
}

.grid-admin {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.tile {
  display: block;
  padding: 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  text-align: center;
}

.tile:hover {
  border-color: var(--accent);
}

.tile strong {
  display: block;
  font-size: 1.5rem;
  color: var(--accent);
}

.tile span {
  font-size: 0.85rem;
  color: var(--muted);
}

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

.table th,
.table td {
  padding: 0.5rem 0.4rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table code {
  font-size: 0.8rem;
  color: var(--accent);
}

.client-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.client-row-main {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.client-bon-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

code {
  background: var(--surface);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
}

.log-pre {
  margin: 0.75rem 0 0;
  padding: 1rem;
  max-height: 70vh;
  overflow: auto;
  background: #0b1220;
  color: #e2e8f0;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.75rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

/* --- Responsive tables --- */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 520px) {
  .row-2 {
    grid-template-columns: 1fr;
  }
}

/* --- Boutons petits et danger --- */
.btn-sm {
  font-size: 0.82rem;
  padding: 0.3rem 0.65rem;
}

.btn-danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.3);
}

.btn-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.btn-warning:hover {
  background: rgba(245, 158, 11, 0.3);
}

.chantier-closed {
  opacity: 0.7;
}

/* --- Édition inline articles / chantiers --- */
.edit-row td {
  background: var(--surface);
  padding: 0.75rem;
}

.form-inline-edit label {
  margin-bottom: 0.45rem;
}

.edit-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.td-actions {
  white-space: nowrap;
}

.th-actions {
  width: 1%;
  white-space: nowrap;
}

/* --- Chantiers admin --- */
.chantier-editor {
  margin-bottom: 0.75rem;
}

.chantier-editor-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.chantier-workers {
  margin: 0.3rem 0 0;
  font-size: 0.82rem;
  color: var(--text);
}

.chantier-bon-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  margin-left: 0.5rem;
}

.chantier-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.chantier-edit-form {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* --- Validation bureau --- */
.validation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* --- Édition bon inline --- */
.edit-mode-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.edit-mode-header h2 {
  margin: 0;
}

.edit-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.dd-pre {
  white-space: pre-wrap;
}

/* --- Statuts par client --- */
.client-status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.4rem;
}

/* --- Plan du site --- */
.sitemap-section {
  font-size: 1rem;
  margin: 1.25rem 0 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
  color: var(--accent);
}

.sitemap-section .muted {
  font-weight: 400;
}

.sitemap {
  margin: 0 0 0.75rem;
  padding: 0;
}

.sitemap dt {
  font-weight: 600;
  font-size: 0.9rem;
  margin-top: 0.65rem;
}

.sitemap dt a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px dashed var(--border);
}

.sitemap dt a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.sitemap dd {
  margin: 0.15rem 0 0 1rem;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.45;
}

/* --- Filter banner --- */
.filter-banner {
  padding: 0.65rem 1rem;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
}

/* --- Bon count link (admin chantiers/clients) --- */
.chantier-bon-link {
  text-decoration: none;
  color: var(--bg);
  background: var(--accent);
  padding: 0.15em 0.55em;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.8rem;
  transition: opacity 0.15s;
}

.chantier-bon-link:hover {
  opacity: 0.8;
}

/* --- Admin sub-navigation --- */
.admin-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.admin-subnav-item {
  padding: 0.4rem 0.75rem;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.admin-subnav-item:hover {
  background: var(--card);
  color: var(--text);
}

.admin-subnav-item.active {
  background: var(--accent);
  color: var(--bg);
}

@media (max-width: 500px) {
  .admin-subnav {
    gap: 0.15rem;
    padding: 0.25rem;
  }
  .admin-subnav-item {
    font-size: 0.75rem;
    padding: 0.35rem 0.55rem;
  }
}

/* --- Photo source & camera --- */
.photo-source-btns {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.photo-source-btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.photo-file-name {
  font-size: 0.85rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.camera-thumb {
  margin-bottom: 0.5rem;
}

.camera-thumb img {
  max-width: 180px;
  max-height: 120px;
  border-radius: 8px;
  border: 2px solid var(--accent);
}

.camera-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.camera-modal-inner {
  background: var(--card);
  border-radius: 14px;
  overflow: hidden;
  max-width: 560px;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.camera-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.camera-modal-inner video {
  width: 100%;
  max-height: 60vh;
  object-fit: cover;
  background: #000;
  flex: 1;
  min-height: 200px;
}

.camera-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
}

@media (max-width: 500px) {
  .camera-modal-inner {
    max-width: 100%;
    border-radius: 0;
    height: 100%;
  }
  .camera-modal-inner video {
    max-height: calc(100vh - 120px);
  }
}

/* --- Dashboard bons --- */
.dashboard-card {
  margin-bottom: 1.5rem;
}

.dashboard-card h2 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

.dashboard-card h3 {
  margin: 1.2rem 0 0.5rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

.dash-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0.5rem;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.dash-number {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
}

.dash-label {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.dash-total .dash-number { color: var(--text); }
.dash-draft .dash-number { color: var(--muted); }
.dash-submitted .dash-number { color: var(--accent); }
.dash-validated .dash-number { color: var(--ok); }

.dash-progress {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 1rem;
  background: var(--surface);
}

.dash-bar {
  height: 100%;
  min-width: 2px;
  transition: width 0.4s ease;
}

.dash-bar-validated { background: var(--ok); }
.dash-bar-submitted { background: var(--accent); }
.dash-bar-draft { background: var(--muted); }

.dash-activity {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.75rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.dash-activity strong {
  color: var(--text);
}

.dash-recent {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.dash-recent-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.88rem;
  transition: border-color 0.15s;
}

.dash-recent-item:hover {
  border-color: var(--accent);
}

.badge-sm {
  font-size: 0.72rem;
  padding: 0.15em 0.55em;
}

.dash-recent-num {
  font-weight: 600;
  min-width: 5.5em;
}

.dash-recent-worker {
  color: var(--muted);
  font-size: 0.82rem;
}

.dash-recent-date {
  color: var(--muted);
  font-size: 0.82rem;
  margin-left: auto;
}

@media (max-width: 600px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dash-activity {
    flex-direction: column;
    gap: 0.35rem;
  }
}

/* --- Sauvegardes --- */
.backup-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin: 0.65rem 0 1rem;
  font-size: 0.9rem;
}

.backup-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.backup-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.backup-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.backup-info strong {
  word-break: break-all;
  font-size: 0.88rem;
}

.backup-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* --- Notification bulle suggestions --- */
.notif-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.notif-btn:hover { color: var(--accent); background: var(--surface); }
.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  background: #ef4444;
  border-radius: 99px;
  padding: 0 4px;
  pointer-events: none;
}

/* --- Paramètres (roue dentée) --- */
.settings-wrap {
  position: relative;
  flex-shrink: 0;
}

.settings-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.settings-btn:hover,
.settings-btn[aria-expanded="true"] {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--card);
}

.settings-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 100;
  width: 240px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

.settings-title {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.65rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--border);
}

.settings-section {
  margin-bottom: 0.65rem;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.theme-options {
  display: flex;
  gap: 0.4rem;
}

.theme-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.45rem 0.25rem;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 500;
  transition: border-color 0.15s;
}

.theme-option:hover {
  border-color: var(--muted);
}

.theme-option.active {
  border-color: var(--accent);
}

.theme-preview {
  display: block;
  width: 28px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.1);
}

.theme-preview-dark {
  background: linear-gradient(135deg, #0f172a 50%, #1e293b 50%);
}

.theme-preview-light {
  background: linear-gradient(135deg, #f1f5f9 50%, #ffffff 50%);
  border-color: rgba(0,0,0,0.15);
}

.theme-preview-custom {
  background: linear-gradient(135deg, #0f172a 40%, var(--accent) 100%);
}

.accent-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.accent-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.accent-dot:hover {
  transform: scale(1.15);
}

.accent-dot.active {
  border-color: var(--text);
}

@media (max-width: 500px) {
  .settings-panel {
    width: calc(100vw - 2rem);
    right: -0.5rem;
  }
}

/* --- Bouton suggestion dans paramètres --- */
.settings-suggest-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s;
}

.settings-suggest-btn:hover {
  border-color: var(--accent);
  background: var(--surface);
}

.settings-link-btn {
  text-decoration: none;
  box-sizing: border-box;
}

.settings-admin-stack {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* --- Server health dashboard --- */
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}
.health-card h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}
.health-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.health-row:last-child { border-bottom: none; }
.health-row-wrap { align-items: flex-start; }
.health-ssl-line {
  max-width: 65%;
  text-align: right;
  word-break: break-word;
  font-size: 0.8rem;
  line-height: 1.35;
}
.health-status { font-weight: 700; text-transform: uppercase; font-size: 0.78rem; }
.health-ok { color: #22c55e; }
.health-warn { color: #f59e0b; }
.health-err { color: #ef4444; }
.health-bar-wrap {
  height: 10px;
  background: var(--surface);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 0.3rem;
}
.health-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 5px;
  transition: width 0.3s;
}
.health-bar-warn { background: #ef4444; }
.health-bar-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.health-pre {
  background: var(--surface);
  padding: 0.6rem;
  border-radius: 6px;
  font-size: 0.75rem;
  overflow-x: auto;
  white-space: pre-wrap;
  color: var(--text);
  margin: 0;
}

/* --- Admin suggestions list --- */
.suggestion-item {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-unread {
  border-left: 3px solid var(--accent);
  background: rgba(245, 158, 11, 0.05);
}
.suggestion-item-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.suggestion-item-body {
  margin: 0.4rem 0 0.5rem;
  white-space: pre-wrap;
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.5;
}
.suggestion-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
}
.suggestion-readers, .suggestion-approvers {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.suggestion-meta-icon {
  font-weight: 600;
  color: var(--muted);
}
.suggestion-meta-full {
  color: #22c55e;
}
.suggestion-reader-name, .suggestion-approver-name {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-size: 0.72rem;
  color: var(--text);
}
.suggestion-approver-name {
  border-color: var(--accent);
  color: var(--accent);
}
.suggestion-item-actions {
  display: flex;
  gap: 0.5rem;
}

/* --- Modale suggestion --- */
.suggestion-overlay[hidden] { display: none; }
.suggestion-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.suggestion-modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
}

.suggestion-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  font-weight: 700;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--border);
}

.suggestion-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 0.25rem;
}

.suggestion-close:hover {
  color: var(--danger);
}

.suggestion-form {
  padding: 1rem;
}

.suggestion-form label {
  display: block;
  margin-bottom: 0.65rem;
  font-size: 0.88rem;
}

.suggestion-form input,
.suggestion-form textarea {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

.suggestion-form input:focus,
.suggestion-form textarea:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.suggestion-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* --- Toast confirmation --- */
.suggestion-toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  padding: 0.65rem 1.25rem;
  border-radius: 10px;
  background: var(--ok);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  animation: toastIn 0.3s ease, toastOut 0.4s ease 4s forwards;
}

.suggestion-toast-err {
  background: var(--danger);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; pointer-events: none; }
}
