/* Règle globale, en tête de fichier : l'attribut `hidden` doit toujours gagner, quelle
   que soit la spécificité d'une règle plus bas (ex. `label { display: block }` avait la
   même spécificité que la règle UA `[hidden]{display:none}` mais la battait car règle
   d'auteur > règle UA — constaté visuellement sur le champ "Statut" resté affiché en
   création). */
[hidden] { display: none !important; }

/* Palette gris-blanc, volontairement quasi monochrome : le "bleu" est réservé aux
   couleurs sémantiques (statuts, types de remarque), pas à l'interface elle-même —
   demande explicite de l'utilisateur ("moins bleu"). Le seul accent est un
   gris-anthracite quasi noir pour les actions principales. */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f0f1f4;
  --border: #e1e3e8;
  --text: #16181d;
  --text-dim: #6b7280;
  --accent: #1f2328;
  --accent-dim: #1f232811;
  --pending: #b45309;
  --pending-dim: #b4530916;
  --danger: #dc2626;
  --danger-dim: #dc262614;
  --ok: #15803d;
  --ok-dim: #15803d16;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,0.04), 0 4px 12px rgba(16,24,40,0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#topbar[hidden] { display: none; }
#topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  color: var(--text);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  margin-left: 6px;
}
.badge-online { background: var(--ok-dim); color: var(--ok); }
.badge-offline { background: var(--danger-dim); color: var(--danger); }

.pending-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--pending);
  background: var(--pending-dim);
  padding: 2px 7px;
  border-radius: 999px;
  vertical-align: middle;
}
.card.pending, a.card.pending, .plan-card.pending {
  border-style: dashed;
  border-color: #d9c199;
  background: #fffaf2;
}
.badge-pending { background: var(--pending-dim); color: var(--pending); }

#app {
  padding: 20px 16px;
  max-width: 900px;
  margin: 0 auto;
  padding-bottom: 90px;
}

h1 {
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  margin: 4px 0 18px;
}
h2, h3 { margin-top: 0; letter-spacing: -0.01em; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 10px;
  transition: color 0.15s;
}
.back-link:hover { color: var(--text); }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

a.card {
  color: var(--text);
  text-decoration: none;
  display: block;
}
a.card:hover { border-color: #c7cad1; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(16,24,40,0.09); }

.list-item strong { display: block; font-size: 1.02rem; margin-bottom: 3px; }
.muted, .empty { color: var(--text-dim); font-size: 0.88rem; }
.empty { font-style: normal; }

.form-card { background: var(--panel-2); border-style: dashed; box-shadow: none; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 auto; }

input, select, textarea, button {
  font: inherit;
  color: var(--text);
  background: #ffffff;
  border: 1px solid #d7dae1;
  border-radius: 10px;
  padding: 10px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #9aa0ab;
  box-shadow: 0 0 0 3px var(--accent-dim);
}
input::placeholder, textarea::placeholder { color: #a3a7b0; }

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 12px;
}
label input, label select, label textarea { width: 100%; margin-top: 5px; font-weight: 400; }

button, a.primary, a.ghost, a.danger {
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
button:active, a.primary:active { transform: scale(0.98); }
/* .primary/.ghost/.danger/.block s'appliquent aussi bien à <button> qu'à <a> (ex. le
   lien de téléchargement du rapport PDF), pas seulement aux boutons. */
.primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: white;
}
.primary:hover { background: #33383f; border-color: #33383f; }
.block { width: 100%; padding: 12px; text-decoration: none; }
.danger {
  background: var(--danger-dim);
  border-color: var(--danger);
  color: var(--danger);
}
.ghost {
  background: transparent;
  border: 1px dashed #c7cad1;
  color: var(--text-dim);
}
.ghost:hover { border-color: #9aa0ab; color: var(--text); }
button:disabled { opacity: 0.55; cursor: default; }

.row .icon-btn { flex: 0 0 auto; background: #ffffff; border: 1px solid #d7dae1; }
.row .icon-btn:hover { background: var(--danger-dim); color: var(--danger); border-color: var(--danger); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--panel-2); }

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton-list { display: flex; flex-direction: column; gap: 10px; }
.skeleton {
  height: 58px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, #eceef1 25%, #f6f7f9 37%, #eceef1 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px 16px;
  color: var(--text-dim);
  text-align: center;
}
.empty-state svg { opacity: 0.35; }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px; padding: 4px; }
.tab {
  flex: 1;
  text-align: center;
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--text-dim);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}
.tab.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }

.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.plan-card { padding: 10px; }
.plan-thumb {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 9px;
  margin-bottom: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}

/* --- Plan annotator --- */
#planScreen { padding: 0; max-width: none; }
.viewport {
  position: fixed;
  top: 54px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  background: #d9dbe0;
  touch-action: none;
  transition: box-shadow 0.2s;
}
.viewport.placing { box-shadow: inset 0 0 0 3px var(--accent); cursor: crosshair; }
.plan-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
}
.plan-wrapper img {
  display: block;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
  box-shadow: 0 2px 24px rgba(0,0,0,0.18);
}
.pin {
  position: absolute;
  width: 32px;
  height: 32px;
  margin-left: -16px;
  margin-top: -16px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(45deg);
  border: 2px solid white;
  color: white;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  cursor: pointer;
  animation: pin-drop 0.25s cubic-bezier(.34,1.56,.64,1);
}
.pin span { transform: rotate(-45deg); }
@keyframes pin-drop { from { transform: rotate(45deg) scale(0); } to { transform: rotate(45deg) scale(1); } }
.pin.pending { opacity: 0.75; border-style: dashed; animation: pin-pulse 1.2s ease-in-out infinite; }
@keyframes pin-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 0.95; } }

.plan-toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 54px;
  z-index: 15;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  padding: 0 10px;
  display: flex;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.plan-toolbar-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-toolbar select { max-width: 140px; padding: 7px 9px; font-size: 0.85rem; }

.hint {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  z-index: 15;
  pointer-events: none;
  box-shadow: var(--shadow);
}

.fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: white;
  box-shadow: 0 6px 20px rgba(31,35,40,0.35);
  z-index: 16;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.fab:active { transform: scale(0.94); }
.fab.active { background: var(--danger); box-shadow: 0 6px 20px rgba(220,38,38,0.4); }

dialog {
  border: none;
  border-radius: 18px;
  padding: 22px;
  background: var(--panel);
  color: var(--text);
  width: min(440px, 92vw);
  box-shadow: 0 20px 60px rgba(16,24,40,0.25);
}
dialog::backdrop { background: rgba(15, 17, 21, 0.45); backdrop-filter: blur(2px); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.type-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}
