/* ============================================================
   ABELLA TERRASSEMENT — Design system BTP industriel
   Optimisé iPad Pro 11" (834×1194 portrait, 1194×834 paysage)
   Direction esthétique : acier, ocre chantier, panneau routier
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* === Palette acier (fond lecture confort — conservée) === */
  --steel-950: #0a0c10;
  --steel-900: #111419;
  --steel-800: #181c23;
  --steel-700: #232831;
  --steel-600: #2e3440;
  --steel-500: #3d4452;
  --steel-400: #5a6373;
  --steel-300: #8b94a3;
  --steel-200: #bdc4d0;
  --steel-100: #e6e9ee;
  --steel-50:  #f5f7fa;

  /* === Jaune CATERPILLAR — accent signature (ex "ocre") === */
  --ocre:        #ffcd11;   /* CAT Yellow */
  --ocre-dark:   #e3b40c;
  --ocre-deep:   #8a6a00;
  --ocre-soft:   rgba(255, 205, 17, 0.12);
  --cat-black:   #0a0c10;   /* noir engin */
  --cat-ink:     #15171c;

  /* Rouge sécurité (alertes, CT à faire) */
  --safety:      #e74c3c;
  --safety-soft: rgba(231, 76, 60, 0.12);

  /* Vert validation */
  --valid:       #2ecc71;
  --valid-soft:  rgba(46, 204, 113, 0.12);

  /* Bleu info */
  --info:        #3498db;
  --info-soft:   rgba(52, 152, 219, 0.12);

  /* Bandes danger chantier (jaune/noir CAT) */
  --hazard: repeating-linear-gradient(
    45deg,
    var(--ocre) 0 14px,
    var(--cat-black) 14px 28px
  );

  /* Plaque à damier (diamond plate) — texture engin */
  --plate:
    linear-gradient(135deg, rgba(255,255,255,.025) 25%, transparent 25%) 0 0/16px 16px,
    linear-gradient(225deg, rgba(255,255,255,.025) 25%, transparent 25%) 0 0/16px 16px,
    linear-gradient(0deg, rgba(0,0,0,.18), rgba(0,0,0,.18));

  /* Typo */
  --font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'JetBrains Mono', 'SF Mono', Menlo, monospace;

  /* Layout */
  --header-h: 64px;
  --sidebar-w: 240px;
  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 14px;

  /* Shadows industrielles */
  --shadow-1: 0 1px 2px rgba(0,0,0,.4), 0 0 0 1px rgba(255,255,255,.04) inset;
  --shadow-2: 0 4px 12px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.05) inset;
  --shadow-3: 0 12px 32px rgba(0,0,0,.6), 0 0 0 1px rgba(255,205,17,.18) inset;
}

/* ============================================================
   RESET / BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--steel-100);
  background: var(--steel-950);
  background-image:
    radial-gradient(1200px 600px at 80% -10%, rgba(245,166,35,.06), transparent 60%),
    radial-gradient(800px 400px at -10% 100%, rgba(52,152,219,.04), transparent 60%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ocre); text-decoration: none; }
a:hover { color: var(--ocre-dark); }

input, textarea, select, button { font-family: inherit; font-size: inherit; }

/* ============================================================
   HEADER (bandeau supérieur)
   ============================================================ */
.app-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: linear-gradient(180deg, var(--steel-900) 0%, var(--steel-800) 100%);
  border-bottom: 2px solid var(--ocre);
  display: flex; align-items: stretch;
  box-shadow: 0 2px 0 var(--steel-900), 0 4px 12px rgba(0,0,0,.4);
}
.app-header::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px;
  height: 2px;
  background: var(--hazard);
  background-size: 28px 28px;
  opacity: .8;
}

.brand-block {
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
  border-right: 1px solid var(--steel-700);
  min-width: var(--sidebar-w);
}
.brand-mark {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: var(--ocre);
  color: var(--steel-950);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 0 var(--ocre-deep), 0 0 0 2px var(--steel-900) inset;
  letter-spacing: .02em;
}
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: .04em;
  color: var(--steel-50);
}
.brand-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--steel-300);
  letter-spacing: .15em;
  margin-top: 2px;
}

.header-info {
  flex: 1;
  display: flex; align-items: center;
  padding: 0 18px;
  gap: 24px;
  overflow: hidden;
}
.info-cell {
  display: flex; flex-direction: column;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.3;
  color: var(--steel-200);
  border-left: 1px solid var(--steel-700);
  padding-left: 16px;
  min-width: 0;
}
.info-cell:first-child { border-left: 0; padding-left: 0; }
.info-label {
  font-size: 9px;
  letter-spacing: .2em;
  color: var(--steel-400);
  text-transform: uppercase;
  margin-bottom: 2px;
}
.info-value { color: var(--steel-50); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.info-value.accent { color: var(--ocre); }

.header-user {
  display: flex; align-items: center;
  padding: 0 18px;
  gap: 12px;
  border-left: 1px solid var(--steel-700);
}
.user-name { font-size: 13px; color: var(--steel-100); font-weight: 600; }
.user-role {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .15em;
  color: var(--ocre);
  text-transform: uppercase;
}

/* DAMOTIC tag dans le header */
.damotic-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: var(--steel-700);
  border: 1px solid var(--steel-600);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .12em;
  color: var(--steel-200);
}
.damotic-tag::before {
  content: ""; width: 6px; height: 6px;
  background: var(--safety);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--safety);
}

/* ============================================================
   LAYOUT
   ============================================================ */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: calc(100vh - var(--header-h));
}

.app-sidebar {
  background: var(--steel-900);
  border-right: 1px solid var(--steel-700);
  padding: 20px 0;
}
.nav-group { margin-bottom: 24px; }
.nav-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .18em;
  color: var(--steel-400);
  padding: 0 20px 8px;
  text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  color: var(--steel-200);
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .15s ease;
  font-size: 14px;
}
.nav-item:hover {
  background: var(--steel-800);
  color: var(--steel-50);
  border-left-color: var(--ocre);
}
.nav-item.active {
  background: linear-gradient(90deg, var(--ocre-soft), transparent);
  color: var(--ocre);
  border-left-color: var(--ocre);
  font-weight: 700;
}
.nav-icon {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  font-size: 16px;
  flex-shrink: 0;
}

.app-main {
  padding: 24px 28px 60px;
  max-width: 100%;
  overflow-x: hidden;
}

/* ============================================================
   PAGE HEADERS
   ============================================================ */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--steel-700);
  position: relative;
}
.page-head::after {
  content: ""; position: absolute; bottom: -1px; left: 0;
  width: 80px; height: 3px;
  background: var(--ocre);
}
.page-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: .04em;
  margin: 0;
  color: var(--steel-50);
  text-transform: uppercase;
}
.page-subtitle {
  color: var(--steel-300);
  font-size: 13px;
  margin: 4px 0 0;
}
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============================================================
   CARTES
   ============================================================ */
.card {
  background: var(--steel-800);
  border: 1px solid var(--steel-700);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--steel-700);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  background: linear-gradient(180deg, var(--steel-700) 0%, var(--steel-800) 100%);
}
.card-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--steel-50);
  margin: 0;
}
.card-body { padding: 18px; }
.card-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .15em;
  color: var(--ocre);
  text-transform: uppercase;
}

/* Grille de cartes */
.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* KPI cards */
.kpi {
  background: var(--steel-800);
  border: 1px solid var(--steel-700);
  border-left: 4px solid var(--ocre);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.kpi-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .18em;
  color: var(--steel-400);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.kpi-value {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 800;
  color: var(--steel-50);
  line-height: 1;
}
.kpi-unit { font-size: 14px; color: var(--steel-400); margin-left: 4px; }
.kpi-meta {
  font-size: 12px;
  color: var(--steel-300);
  margin-top: 6px;
}
.kpi.alert { border-left-color: var(--safety); }
.kpi.alert .kpi-value { color: var(--safety); }
.kpi.ok { border-left-color: var(--valid); }
.kpi.info { border-left-color: var(--info); }

/* ============================================================
   BOUTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--steel-600);
  background: var(--steel-700);
  color: var(--steel-100);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: all .12s ease;
  min-height: 42px; /* tap target iPad */
  font-family: var(--font-body);
  letter-spacing: .02em;
}
.btn:hover { background: var(--steel-600); border-color: var(--steel-500); color: var(--steel-50); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--ocre);
  border-color: var(--ocre-dark);
  color: var(--steel-950);
  font-weight: 700;
  box-shadow: 0 2px 0 var(--ocre-deep);
}
.btn-primary:hover { background: var(--ocre-dark); color: var(--steel-950); }
.btn-danger {
  background: var(--safety);
  border-color: #b03828;
  color: white;
  box-shadow: 0 2px 0 #7a2618;
}
.btn-danger:hover { background: #c0392b; color: white; }
.btn-ghost {
  background: transparent;
  border-color: var(--steel-600);
  color: var(--steel-200);
}
.btn-block { width: 100%; }
.btn-icon { font-size: 16px; }
.btn-sm { padding: 6px 12px; min-height: 32px; font-size: 12px; }

/* ============================================================
   FORMULAIRES
   ============================================================ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 20px;
}
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

.field {
  display: flex; flex-direction: column;
  gap: 6px;
}
.field-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .12em;
  color: var(--steel-300);
  text-transform: uppercase;
  font-weight: 500;
}
.field-label.required::after { content: " *"; color: var(--ocre); }

.field input[type="text"],
.field input[type="email"],
.field input[type="tel"],
.field input[type="password"],
.field input[type="number"],
.field input[type="date"],
.field input[type="time"],
.field input[type="url"],
.field input[type="search"],
.field textarea,
.field select {
  background: var(--steel-900);
  border: 1px solid var(--steel-600);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--steel-50);
  font-size: 15px;
  transition: all .12s ease;
  min-height: 44px; /* iPad tap target */
  width: 100%;
}
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--ocre);
  box-shadow: 0 0 0 3px var(--ocre-soft);
  background: var(--steel-950);
}

.field-help {
  font-size: 11px;
  color: var(--steel-400);
  font-style: italic;
}

.fieldset {
  border: 1px solid var(--steel-700);
  border-radius: var(--radius);
  padding: 18px 20px 22px;
  margin-bottom: 18px;
  background: rgba(255,255,255,.02);
}
.fieldset legend {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ocre);
  padding: 0 10px;
}

/* ============================================================
   TABLEAUX
   ============================================================ */
.table-wrap {
  background: var(--steel-800);
  border: 1px solid var(--steel-700);
  border-radius: var(--radius);
  overflow: auto;
  box-shadow: var(--shadow-2);
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.data thead th {
  background: var(--steel-700);
  color: var(--steel-200);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  text-align: left;
  padding: 12px 14px;
  border-bottom: 2px solid var(--ocre);
  white-space: nowrap;
}
table.data tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--steel-700);
  color: var(--steel-100);
  vertical-align: middle;
}
table.data tbody tr:hover { background: var(--steel-700); }
table.data tbody tr:last-child td { border-bottom: 0; }

.cell-num { font-family: var(--font-mono); font-weight: 600; color: var(--ocre); }
.cell-mono { font-family: var(--font-mono); font-size: 12px; }

/* ============================================================
   BADGES / STATUTS
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  border: 1px solid transparent;
}
.badge-ocre  { background: var(--ocre-soft); color: var(--ocre); border-color: rgba(245,166,35,.3); }
.badge-info  { background: var(--info-soft); color: var(--info); border-color: rgba(52,152,219,.3); }
.badge-valid { background: var(--valid-soft); color: var(--valid); border-color: rgba(39,174,96,.3); }
.badge-alert { background: var(--safety-soft); color: var(--safety); border-color: rgba(231,76,60,.3); }
.badge-mute  { background: var(--steel-700); color: var(--steel-300); border-color: var(--steel-600); }

/* Statuts dossier */
.statut-prospect    { background: var(--info-soft); color: var(--info); }
.statut-devis       { background: rgba(155,89,182,.12); color: #9b59b6; }
.statut-en_cours    { background: var(--ocre-soft); color: var(--ocre); }
.statut-suspendu    { background: rgba(127,140,141,.12); color: #95a5a6; }
.statut-termine     { background: var(--valid-soft); color: var(--valid); }
.statut-facture     { background: rgba(22,160,133,.12); color: #16a085; }
.statut-annule      { background: var(--safety-soft); color: var(--safety); }

/* ============================================================
   RECHERCHE GLOBALE
   ============================================================ */
.search-box {
  position: relative;
  margin-bottom: 18px;
}
.search-box input {
  width: 100%;
  background: var(--steel-800);
  border: 1px solid var(--steel-700);
  border-left: 3px solid var(--ocre);
  border-radius: var(--radius);
  padding: 14px 14px 14px 46px;
  color: var(--steel-50);
  font-size: 16px;
  min-height: 48px;
}
.search-box::before {
  content: "⌕";
  position: absolute;
  left: 16px; top: 50%; transform: translateY(-50%);
  color: var(--ocre);
  font-size: 20px;
}
.search-box input:focus {
  outline: none;
  border-color: var(--ocre);
  box-shadow: 0 0 0 3px var(--ocre-soft);
}

/* Résultats recherche transverse */
.search-results {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}
.search-result-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px;
  background: var(--steel-800);
  border: 1px solid var(--steel-700);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--steel-100);
  transition: all .12s ease;
}
.search-result-item:hover {
  border-color: var(--ocre);
  background: var(--steel-700);
  color: var(--steel-50);
}
.search-result-type {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .15em;
  color: var(--ocre);
  text-transform: uppercase;
  min-width: 90px;
}

/* ============================================================
   FLASH MESSAGES
   ============================================================ */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  border-left: 3px solid;
  font-weight: 500;
  font-size: 14px;
}
.flash-success { background: var(--valid-soft); border-left-color: var(--valid); color: var(--valid); }
.flash-error   { background: var(--safety-soft); border-left-color: var(--safety); color: var(--safety); }
.flash-info    { background: var(--info-soft); border-left-color: var(--info); color: var(--info); }
.flash-warning { background: var(--ocre-soft); border-left-color: var(--ocre); color: var(--ocre); }

/* ============================================================
   PAGE LOGIN
   ============================================================ */
.login-body {
  display: grid; place-items: center;
  min-height: 100vh;
  padding: 20px;
  background: var(--steel-950);
  position: relative;
}
.login-bg {
  position: fixed; inset: 0;
  background:
    repeating-linear-gradient(45deg,
      transparent 0 80px,
      rgba(245,166,35,.02) 80px 82px),
    radial-gradient(800px 500px at 20% 20%, rgba(245,166,35,.08), transparent 60%),
    radial-gradient(900px 600px at 80% 80%, rgba(52,152,219,.04), transparent 60%);
  pointer-events: none;
  z-index: 0;
}
.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 460px;
  background: var(--steel-800);
  border: 1px solid var(--steel-700);
  border-top: 4px solid var(--ocre);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  overflow: hidden;
}
.login-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  background: var(--steel-900);
  border-bottom: 1px solid var(--steel-700);
}
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .12em;
  color: var(--steel-400);
}
.login-form { padding: 28px 30px 22px; }
.login-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin: 0 0 4px;
  color: var(--steel-50);
}
.login-subtitle {
  font-size: 13px;
  color: var(--steel-300);
  margin: 0 0 22px;
}
.login-form .field { margin-bottom: 14px; }
.login-footer {
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 22px;
  background: var(--steel-900);
  border-top: 1px solid var(--steel-700);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .08em;
  color: var(--steel-400);
  text-align: center;
}
.login-footer strong { color: var(--ocre); letter-spacing: .12em; }

/* ============================================================
   RESPONSIVE iPad 11" et plus petit
   ============================================================ */
@media (max-width: 1024px) {
  :root { --sidebar-w: 200px; }
  .brand-block { min-width: var(--sidebar-w); padding: 0 14px; }
  .info-cell { padding-left: 12px; }
  .info-cell:nth-child(n+4) { display: none; }
}
@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-sidebar {
    position: fixed; left: 0; top: var(--header-h);
    width: 240px; height: calc(100vh - var(--header-h));
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 50;
  }
  .app-sidebar.open { transform: translateX(0); }
  .info-cell:nth-child(n+3) { display: none; }
  .app-main { padding: 16px; }
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes pulse-ocre {
  0%, 100% { box-shadow: 0 0 0 0 var(--ocre-soft); }
  50%      { box-shadow: 0 0 0 6px transparent; }
}
.live-dot {
  display: inline-block;
  width: 8px; height: 8px;
  background: var(--valid);
  border-radius: 50%;
  animation: pulse-ocre 2s infinite;
  box-shadow: 0 0 8px var(--valid);
}

/* ============================================================
   ONGLETS LISTE / CARTE
   ============================================================ */
.view-tabs {
  display: inline-flex;
  background: var(--steel-800);
  border: 1px solid var(--steel-700);
  border-radius: var(--radius);
  padding: 4px;
  gap: 4px;
  margin-bottom: 18px;
}
.view-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--steel-300);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: all .12s ease;
  min-height: 36px;
}
.view-tab:hover {
  background: var(--steel-700);
  color: var(--steel-50);
}
.view-tab.active {
  background: var(--ocre);
  color: var(--steel-950);
  font-weight: 700;
  box-shadow: 0 2px 0 var(--ocre-deep);
}
.view-tab-icon { font-size: 14px; }

/* ============================================================
   CARTE
   ============================================================ */
.map-wrap {
  background: var(--steel-800);
  border: 1px solid var(--steel-700);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-2);
}
.map-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--steel-700);
  background: linear-gradient(180deg, var(--steel-700) 0%, var(--steel-800) 100%);
  flex-wrap: wrap;
  gap: 8px;
}
.map-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--steel-50);
  margin: 0;
}
.map-status {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--ocre);
  text-transform: uppercase;
}
.map-canvas {
  height: 600px;
  width: 100%;
  background: var(--steel-900);
}
@media (max-width: 820px) {
  .map-canvas { height: 480px; }
}

.map-error {
  padding: 30px;
  text-align: center;
  color: var(--safety);
  font-family: var(--font-mono);
}

/* Pin custom pour Leaflet */
.abl-pin {
  background: transparent;
  border: 0;
}
.abl-pin-inner {
  width: 28px; height: 28px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid var(--steel-950);
  box-shadow: 0 2px 6px rgba(0,0,0,.5);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--steel-950);
}
.abl-pin-inner > * {
  transform: rotate(45deg);
}

/* Forcer le fond sombre sur les attributions Leaflet */
.leaflet-control-attribution {
  background: rgba(20, 24, 31, .8) !important;
  color: var(--steel-300) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--ocre) !important; }
.leaflet-popup-content-wrapper {
  background: var(--steel-50) !important;
  border-radius: var(--radius) !important;
}

/* Bandeau "ville inconnue" pour items sans coord */
.map-orphans {
  padding: 14px 18px;
  background: rgba(245, 166, 35, 0.06);
  border-top: 1px solid var(--steel-700);
  font-size: 13px;
  color: var(--steel-300);
}
.map-orphans strong { color: var(--ocre); }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding: 14px 18px;
  background: var(--steel-800);
  border: 1px solid var(--steel-700);
  border-radius: var(--radius);
}

.pagination-info {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--steel-300);
  letter-spacing: .03em;
}
.pagination-info strong {
  color: var(--ocre);
  font-weight: 700;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.pg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--steel-600);
  background: var(--steel-700);
  color: var(--steel-100);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  transition: all .12s ease;
  user-select: none;
}
.pg-btn:hover:not(.disabled):not(.current) {
  background: var(--steel-600);
  border-color: var(--ocre);
  color: var(--ocre);
}
.pg-btn.current {
  background: var(--ocre);
  border-color: var(--ocre-dark);
  color: var(--steel-950);
  cursor: default;
  box-shadow: 0 2px 0 var(--ocre-deep);
}
.pg-btn.disabled {
  opacity: .35;
  cursor: not-allowed;
  pointer-events: none;
}
.pg-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  color: var(--steel-400);
  font-family: var(--font-mono);
  font-size: 14px;
}

.pg-jump {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 10px;
  padding-left: 12px;
  border-left: 1px solid var(--steel-600);
}
.pg-jump-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .12em;
  color: var(--steel-400);
  text-transform: uppercase;
}
.pg-jump-input {
  width: 64px;
  height: 38px;
  padding: 0 8px;
  background: var(--steel-900);
  border: 1px solid var(--steel-600);
  border-radius: var(--radius-sm);
  color: var(--steel-50);
  font-family: var(--font-mono);
  font-size: 13px;
  text-align: center;
}
.pg-jump-input:focus {
  outline: none;
  border-color: var(--ocre);
  box-shadow: 0 0 0 3px var(--ocre-soft);
}
.pg-jump-go {
  background: var(--ocre);
  color: var(--steel-950);
  border-color: var(--ocre-dark);
  font-weight: 700;
}
.pg-jump-go:hover {
  background: var(--ocre-dark) !important;
  color: var(--steel-950) !important;
}

@media (max-width: 700px) {
  .pagination-bar { flex-direction: column; align-items: stretch; }
  .pagination { justify-content: center; }
  .pg-jump { margin-left: 0; padding-left: 0; border-left: 0; justify-content: center; }
}

/* ============================================================
   UTILITAIRES
   ============================================================ */
.mono { font-family: var(--font-mono); }
.muted { color: var(--steel-400); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; }
.flex-gap { display: flex; gap: 12px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.hidden { display: none !important; }

/* Photo thumb */
.thumb {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  background: var(--steel-700);
  border: 1px solid var(--steel-600);
  object-fit: cover;
  display: block;
}
.thumb-lg { width: 72px; height: 72px; }
.thumb-placeholder {
  display: grid; place-items: center;
  color: var(--steel-400);
  font-size: 18px;
  font-family: var(--font-display);
  font-weight: 700;
}

/* ============================================================
   v2.0 — DIRECTION CATERPILLAR / MINIER / FORAGE
   (ajouts ; n'altère pas les classes existantes)
   ============================================================ */

/* Plaque à damier + noir engin sur header & sidebar */
.app-header {
  background: var(--cat-ink);
  background-image: var(--plate);
  border-bottom: 3px solid var(--ocre);
}
.app-header::before { height: 4px; opacity: .95; }
.app-sidebar {
  background: var(--cat-ink);
  background-image:
    linear-gradient(180deg, rgba(255,205,17,.04), transparent 120px),
    var(--plate);
}
.brand-mark {
  background: var(--ocre);
  box-shadow: 0 2px 0 var(--ocre-deep), 0 0 0 2px var(--cat-black) inset;
  border: 1px solid var(--ocre-dark);
}

/* Rail danger fin sous le header (renfort minier) */
.app-shell { position: relative; }

/* Boutons primaires = plaque CAT jaune/noir */
.btn-primary {
  background: linear-gradient(180deg, #ffd633, var(--ocre));
  color: var(--cat-black);
  border-color: var(--ocre-dark);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 800;
}
.btn-primary:hover { background: var(--ocre-dark); color: var(--cat-black); }

/* Titres de page : liseré jaune/noir */
.page-head::after { background: var(--hazard); background-size: 18px 18px; height: 4px; width: 110px; }

/* ============================================================
   FENÊTRES DE DONNÉES (panneaux scrollables V + H)
   .win > .win-bar + .win-body(.table-wrap)
   Généré automatiquement par app.js autour de chaque .table-wrap
   ============================================================ */
.win {
  background: var(--steel-800);
  border: 1px solid var(--steel-700);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  overflow: hidden;
  margin-bottom: 4px;
}
.win-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: var(--cat-ink);
  background-image: var(--plate);
  border-bottom: 2px solid var(--ocre);
  user-select: none;
}
.win-bar .win-dots { display: inline-flex; gap: 5px; }
.win-bar .win-dots i {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--steel-600); border: 1px solid var(--steel-500);
}
.win-bar .win-dots i:first-child { background: var(--ocre); border-color: var(--ocre-dark); }
.win-title {
  font-family: var(--font-display);
  font-size: 15px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--steel-50);
  display: flex; align-items: center; gap: 8px;
}
.win-title .win-ico { color: var(--ocre); }
.win-meta {
  margin-left: auto;
  display: flex; align-items: center; gap: 12px;
  font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--steel-400);
}
.win-meta .win-count strong { color: var(--ocre); }
.win-scrollhint { color: var(--steel-500); }

/* corps : la .table-wrap devient la zone de défilement V+H */
.win > .table-wrap {
  border: 0; border-radius: 0; box-shadow: none;
  margin: 0;
  max-height: min(62vh, 640px);
  overflow: auto;
  scrollbar-color: var(--ocre) var(--steel-800);
}
.win > .table-wrap::-webkit-scrollbar { width: 12px; height: 12px; }
.win > .table-wrap::-webkit-scrollbar-track { background: var(--steel-900); }
.win > .table-wrap::-webkit-scrollbar-thumb {
  background: var(--steel-600); border-radius: 8px;
  border: 3px solid var(--steel-900);
}
.win > .table-wrap::-webkit-scrollbar-thumb:hover { background: var(--ocre-deep); }
.win > .table-wrap::-webkit-scrollbar-corner { background: var(--steel-900); }

/* en-têtes figés pendant le scroll vertical interne */
.win table.data thead th {
  position: sticky; top: 0; z-index: 3;
  box-shadow: 0 2px 0 var(--ocre);
}

/* Lignes cliquables (généralisé sur tout le site) */
table.data tbody tr.row-link { cursor: pointer; }
table.data tbody tr.row-link:hover {
  background: linear-gradient(90deg, var(--ocre-soft), var(--steel-700));
  box-shadow: inset 3px 0 0 var(--ocre);
}
table.data tbody tr.row-link:active { background: var(--steel-600); }
.row-open-hint { color: var(--ocre); font-family: var(--font-mono); font-size: 11px; }

/* ============================================================
   RECHERCHE GLOBALE DANS LE HEADER (présente sur toutes les pages)
   ============================================================ */
.header-search {
  position: relative;
  display: flex; align-items: center;
  margin-left: auto;
  min-width: 220px; max-width: 360px; flex: 0 1 320px;
}
.header-search input {
  width: 100%;
  background: var(--steel-900);
  border: 1px solid var(--steel-700);
  border-left: 3px solid var(--ocre);
  border-radius: var(--radius-sm);
  padding: 9px 12px 9px 36px;
  color: var(--steel-50);
  font-size: 13px;
  min-height: 40px;
}
.header-search input:focus {
  outline: none; border-color: var(--ocre);
  box-shadow: 0 0 0 3px var(--ocre-soft);
}
.header-search::before {
  content: "⌕"; position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%); color: var(--ocre); font-size: 18px;
}
.header-search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--steel-800);
  border: 1px solid var(--steel-600);
  border-top: 3px solid var(--ocre);
  border-radius: var(--radius);
  box-shadow: var(--shadow-3);
  max-height: 70vh; overflow: auto;
  z-index: 200; display: none;
}
.header-search-results.open { display: block; }
.header-search-results .search-result-item { border-radius: 0; border-left: 0; border-right: 0; }
.header-search-results .gs-group {
  font-family: var(--font-mono); font-size: 10px; letter-spacing:.16em;
  text-transform: uppercase; color: var(--ocre);
  padding: 8px 14px 4px; background: var(--steel-900);
}
@media (max-width: 1024px) { .header-search { display: none; } }

/* ============================================================
   MODULE BATIGEST
   ============================================================ */
.bg-hero {
  display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center;
  background: var(--cat-ink); background-image: var(--plate);
  border: 1px solid var(--steel-700); border-left: 5px solid var(--ocre);
  border-radius: var(--radius); padding: 18px 22px; margin-bottom: 20px;
}
.bg-hero .bg-emblem {
  width: 60px; height: 60px; display: grid; place-items: center;
  background: var(--ocre); color: var(--cat-black);
  font-size: 30px; border-radius: var(--radius-sm);
  box-shadow: 0 2px 0 var(--ocre-deep);
}
.bg-hero h2 { font-family: var(--font-display); font-size: 26px; text-transform: uppercase; letter-spacing:.04em; margin:0; color: var(--steel-50); }
.bg-hero .sub { color: var(--steel-300); font-size: 13px; margin-top: 2px; }
.registre-link { cursor: pointer; }

/* ============================================================
   v2.1 — Liens d'entités dans les fenêtres (cross-navigation)
   ============================================================ */
.entity-link {
  color: var(--steel-50);
  text-decoration: none;
  border-bottom: 1px dotted var(--steel-500);
  cursor: pointer;
  transition: color .12s ease, border-color .12s ease;
}
.entity-link:hover {
  color: var(--ocre);
  border-bottom-color: var(--ocre);
}
.entity-link strong { color: inherit; }
/* Pastille au survol pour signaler la navigation */
table.data tbody td .entity-link { position: relative; }
.cell-num.entity-link, .cell-num .entity-link { color: var(--ocre); }
