:root {
  --blue: #1226AA;
  --blue-soft: #E8EBF8;
  --coral: #FF8672;
  --coral-dark: #F06A54;
  --teal: #3BD4AE;
  --green: #D2EA8E;
  --yellow: #ECD925;
  --pink: #FFBE9F;
  --ink: #1226AA;
  --muted: #5B66A8;
  --line: #DADFF2;
  --bg: #F6F7FC;
  --surface: #FFFFFF;
  --danger: #D93A3A;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(18, 38, 170, .10);
  --font: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; -webkit-font-smoothing: antialiased; }
a { color: var(--blue); }
h1, h2, h3 { font-weight: 900; margin: 0 0 .5em; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* ---------- Boutons et champs ---------- */
.btn {
  font: inherit; font-weight: 700; border: 1.5px solid var(--line); background: var(--surface); color: var(--blue);
  padding: 9px 16px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--blue); }
.btn.primary { background: var(--coral); border-color: var(--coral); color: #fff; }
.btn.primary:hover { background: var(--coral-dark); border-color: var(--coral-dark); }
.btn.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--blue-soft); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.sm { padding: 5px 11px; font-size: 13px; }
.btn.icon { padding: 7px; width: 34px; height: 34px; justify-content: center; }
.btn:disabled { opacity: .5; cursor: default; }

label.field { display: block; margin-bottom: 14px; font-weight: 700; font-size: 14px; }
input[type=text], input[type=email], input[type=password], input[type=url], textarea, select {
  font: inherit; color: var(--ink); width: 100%; padding: 10px 12px; border: 1.5px solid var(--line);
  border-radius: 10px; background: #fff; margin-top: 5px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--blue); }
.error { color: var(--danger); font-weight: 600; min-height: 1.2em; margin: 6px 0; }

/* ---------- Structure des pages ---------- */
.topbar {
  height: 60px; display: flex; align-items: center; gap: 14px; padding: 0 20px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: relative; z-index: 20;
}
.brand { font-weight: 900; font-size: 19px; color: var(--blue); text-decoration: none; display: flex; align-items: center; gap: 9px; }
.brand-logo { width: 32px; height: 32px; display: block; flex: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 58% 42% 55% 45% / 50% 55% 45% 50%; background: var(--coral); display: grid; place-items: center; color: #fff; font-size: 15px; }
.spacer { flex: 1; }
.container { max-width: 1040px; margin: 0 auto; padding: 32px 20px 60px; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.auth-wrap { min-height: calc(100vh - 60px); display: grid; place-items: center; padding: 20px; position: relative; overflow: hidden; }
.auth-wrap .card { width: 100%; max-width: 400px; position: relative; z-index: 1; }
.blob { position: absolute; z-index: 0; opacity: .55; }
.blob.a { width: 380px; height: 340px; background: var(--teal); top: -120px; left: -110px; border-radius: 62% 38% 46% 54% / 55% 45% 55% 45%; }
.blob.b { width: 300px; height: 280px; background: var(--pink); bottom: -100px; right: -60px; border-radius: 40% 60% 60% 40% / 45% 40% 60% 55%; }

.maps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; margin-top: 20px; }
.map-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; gap: 10px; min-height: 140px; }
.map-card a.title { font-weight: 800; font-size: 17px; text-decoration: none; color: var(--blue); flex: 1; word-break: break-word; }
.map-card a.title:hover { text-decoration: underline; }
.map-card .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.map-card.new { border: 2px dashed var(--line); box-shadow: none; background: transparent; align-items: center; justify-content: center; cursor: pointer; color: var(--muted); font-weight: 800; }
.map-card.new:hover { border-color: var(--coral); color: var(--coral); }
.empty { text-align: center; padding: 40px; }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data th { font-weight: 800; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.table-scroll { overflow-x: auto; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; background: var(--blue-soft); color: var(--blue); }
.badge.admin { background: var(--coral); color: #fff; }
.badge.off { background: #eee; color: #888; }
.badge.edit { background: var(--teal); color: #08324a; }
.stats { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.stat { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 20px; min-width: 140px; }
.stat b { display: block; font-size: 26px; font-weight: 900; }

/* ---------- Menus et fenêtres ---------- */
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--line); min-width: 200px; padding: 6px; z-index: 50; }
.menu-list a, .menu-list button { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 8px; border: 0; background: none; font: inherit; color: var(--ink); text-decoration: none; cursor: pointer; }
.menu-list a:hover, .menu-list button:hover { background: var(--blue-soft); }
.menu-list .who { padding: 8px 12px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }

.modal-back { position: fixed; inset: 0; background: rgba(18, 38, 170, .25); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; width: 100%; max-width: 480px; max-height: 90vh; overflow: auto; }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--blue); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 700; z-index: 200; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.toast.err { background: var(--danger); }

@media (max-width: 600px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .container { padding: 20px 16px 40px; }
  .hide-sm { display: none !important; }
}

/* ---------- Tableau de bord : dossiers ---------- */
.dash-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.dash-head .search { max-width: 280px; margin: 0; border-radius: 999px; padding: 8px 16px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.crumbs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-weight: 800; }
.crumb { text-decoration: none; padding: 5px 10px; border-radius: 8px; color: var(--blue); }
.crumb:hover { background: var(--blue-soft); }
.crumbs .sep { color: var(--muted); }
.crumbs .crumb:last-child { color: var(--muted); }
.map-card.folder { background: var(--blue-soft); box-shadow: none; border: 1.5px solid transparent; }
.map-card.folder a.title { display: flex; align-items: center; gap: 10px; }
.folder-icon { width: 26px; height: 20px; border-radius: 4px 6px 6px 6px; background: var(--coral); position: relative; flex: none; }
.folder-icon::before { content: ''; position: absolute; left: 0; top: -5px; width: 12px; height: 7px; border-radius: 3px 3px 0 0; background: var(--coral); }
.map-card[draggable="true"] { cursor: grab; }
.map-card.dragging { opacity: .4; }
.drop-target { outline: 3px solid var(--teal); outline-offset: 2px; background: rgba(59, 212, 174, .15) !important; }
@media (max-width: 600px) { .dash-head .search { max-width: none; width: 100%; } }
