/* RISC-GTI — UI Contacts transverse
   Déclinaison visuelle alignée sur l'UI Location : surfaces claires, pills compactes, pipeline relationnel.
   Aucun asset externe requis. */

:root {
  --gti-bg: #f4efe6;
  --gti-card: rgba(255, 253, 248, .95);
  --gti-card-soft: rgba(255, 255, 255, .82);
  --gti-border: rgba(196, 171, 128, .45);
  --gti-text: #312817;
  --gti-muted: #6f6a60;
  --gti-primary: #087982;
  --gti-primary-dark: #006671;
  --gti-accent: #d8c8a9;
  --gti-warn: #dd8a20;
  --gti-critical: #c9433d;
  --gti-ok: #46876c;
  --gti-shadow: 0 14px 34px rgba(32, 28, 20, .08);
}

* { box-sizing: border-box; }

body.gti-page-shell {
  margin: 0;
  min-height: 100vh;
  color: var(--gti-text);
  background:
    radial-gradient(circle at 25% 0%, rgba(255,255,255,.85), transparent 36%),
    linear-gradient(180deg, #f8f4ec 0%, #f3eee5 48%, #fffaf0 100%);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.gti-production-page { padding: 14px; }

.desktop-topbar {
  min-height: 76px;
  padding: 10px 14px;
  border: 1px solid var(--gti-border);
  border-radius: 20px;
  background: var(--gti-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  box-shadow: var(--gti-shadow);
}

.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 250px; }

.drawer-toggle {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  border: 1px solid var(--gti-border);
  background: #fff;
  color: var(--gti-text);
  font-size: 26px;
  cursor: pointer;
}

.txt h1 { margin: 0; font-size: 30px; line-height: 1; letter-spacing: -.04em; }
.txt p { margin: 4px 0 0; color: var(--gti-muted); }

.topbar-status-pills { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }

.status-pill {
  height: 42px;
  border: 1px solid var(--gti-border);
  border-radius: 999px;
  padding: 0 13px;
  background: rgba(255,255,255,.92);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--gti-text);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(35, 29, 20, .05);
}

.status-pill.is-active { outline: 2px solid rgba(8,121,130,.18); }
.pill-icon {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; background: var(--gti-primary);
  font-size: 14px; font-weight: 900;
}
.status-warning .pill-icon { background: var(--gti-warn); }
.status-ok .pill-icon { background: var(--gti-ok); }
.status-neutral .pill-icon { background: #8a8172; }
.status-critical .pill-icon { background: var(--gti-critical); }

.gti-production-body { margin-top: 12px; }

.gti-body-block {
  border: 1px solid var(--gti-border);
  border-radius: 24px;
  background: var(--gti-card);
  box-shadow: var(--gti-shadow);
  padding: 22px;
}

.gti-fiche-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.gti-kicker {
  margin: 0 0 5px;
  color: var(--gti-muted);
  font-weight: 700;
}

.gti-body-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.08;
  letter-spacing: -.035em;
}

.gti-body-intro { margin: 8px 0 0; color: var(--gti-muted); }

.gti-head-badges { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.gti-status {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 28px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  background: #eef5f5;
  color: var(--gti-primary-dark);
}
.gti-status.warn { background: #fff6df; color: #8a5a09; }
.gti-status.neutral { background: #eef1f1; color: #5e6870; }
.gti-status.ok { background: #eaf7ef; color: #276749; }
.gti-status.error { background: #fff0ef; color: #9f1d1a; }

.contacts-command-panel {
  border: 1px solid var(--gti-border);
  border-radius: 18px;
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 220px 220px auto;
  gap: 12px;
  align-items: end;
  background: rgba(255,255,255,.72);
}

.gti-field {
  display: flex; flex-direction: column; gap: 6px;
}
.gti-field label {
  font-size: 13px; color: #60707a; font-weight: 800;
}
.gti-field input,
.gti-field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--gti-border);
  border-radius: 12px;
  padding: 0 12px;
  background: #fff;
  color: var(--gti-text);
  font-size: 15px;
  font-weight: 700;
}

.contacts-actions, .gti-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.gti-actions.stack { flex-direction: column; align-items: stretch; }

.gti-btn {
  border: 1px solid var(--gti-border);
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  font-weight: 900;
  cursor: pointer;
  background: #fff;
}
.gti-btn.primary {
  color: #fff;
  background: var(--gti-primary);
  border-color: var(--gti-primary);
}
.gti-btn.primary:hover { background: var(--gti-primary-dark); }
.gti-btn.secondary { color: var(--gti-text); background: #fff; }

.gti-api-status {
  margin: 12px 0;
  min-height: 32px;
  padding: 8px 12px;
  border-radius: 14px;
  background: #f5f8f8;
  color: #50636a;
  font-weight: 700;
}

.contacts-create-panel {
  margin: 12px 0;
  border: 1px solid var(--gti-border);
  border-radius: 18px;
  padding: 16px;
  background: rgba(255,255,255,.86);
}
.contacts-create-panel h3 { margin: 0 0 12px; }
.gti-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 12px;
}
.contacts-rule-note { color: var(--gti-muted); font-size: 13px; font-weight: 700; }

.contacts-layout {
  display: grid;
  grid-template-columns: minmax(430px, 1.2fr) minmax(320px, .8fr);
  gap: 14px;
}

.contacts-list-panel,
.contacts-detail-panel {
  min-height: 430px;
  border: 1px solid var(--gti-border);
  border-radius: 18px;
  padding: 14px;
  background: rgba(255,255,255,.78);
}

.panel-title-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  border-bottom: 1px solid rgba(196,171,128,.25);
  padding-bottom: 10px;
  margin-bottom: 12px;
}
.panel-title-row h3 { margin: 0; font-size: 18px; }

.contacts-list {
  display: grid;
  gap: 10px;
  max-height: 58vh;
  overflow: auto;
  padding-right: 4px;
}

.contact-row {
  width: 100%;
  border: 1px solid rgba(196,171,128,.42);
  border-radius: 16px;
  background: rgba(255,255,255,.94);
  padding: 12px;
  text-align: left;
  cursor: pointer;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}
.contact-row:hover,
.contact-row.is-selected {
  border-color: rgba(8,121,130,.7);
  box-shadow: 0 0 0 3px rgba(8,121,130,.09);
}
.contact-avatar,
.contact-mini-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--gti-primary);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 900;
}
.contact-avatar { width: 72px; height: 72px; font-size: 30px; margin: 8px auto 12px; }

.contact-main strong { display:block; font-size: 16px; }
.contact-main span { display:block; color: var(--gti-muted); font-size: 13px; margin-top: 3px; }

.contact-flags { display:flex; flex-direction: column; align-items: flex-end; gap:6px; }
.contact-flag {
  padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 900;
  background: #eef1f1; color: #51626a;
}
.contact-flag.warn { background: #fff6df; color: #8a5a09; }
.contact-flag.ok { background: #eaf7ef; color: #276749; }

.contacts-empty {
  display: grid; place-items: center; min-height: 260px;
  color: var(--gti-muted);
  text-align: center;
  font-weight: 800;
}

.contacts-detail { text-align: center; }
.contacts-detail h4 { margin: 0; font-size: 22px; }
.contacts-detail p { margin: 6px 0 14px; color: var(--gti-muted); }

.gti-quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px;
  margin: 12px 0;
}
.gti-quick-grid.compact { grid-template-columns: repeat(2, minmax(0,1fr)); }
.gti-quick-item {
  border: 1px solid rgba(196,171,128,.35);
  border-radius: 14px;
  padding: 10px;
  text-align: left;
  background: rgba(255,255,255,.7);
}
.gti-quick-item span { display: block; color: var(--gti-muted); font-size: 12px; font-weight: 800; }
.gti-quick-item strong { display: block; margin-top: 4px; font-size: 14px; overflow-wrap: anywhere; }

.contacts-usage-help {
  border-radius: 14px;
  padding: 10px;
  margin: 12px 0;
  background: #f4f8f8;
  color: #4d6269;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
}

.contacts-footer {
  position: sticky; bottom: 0; margin-top: 10px;
  min-height: 64px; display: flex; align-items: center; justify-content: center; gap: 60px;
  background: rgba(255,253,248,.9);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(196,171,128,.3);
}
.footer-icon {
  border: none; background: transparent; font-size: 22px; cursor: pointer;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,.18));
}

@media (max-width: 980px) {
  .desktop-topbar,
  .gti-fiche-head { flex-direction: column; align-items: stretch; }
  .topbar-status-pills { justify-content: flex-start; }
  .contacts-command-panel { grid-template-columns: 1fr; }
  .contacts-layout { grid-template-columns: 1fr; }
  .contacts-list { max-height: none; }
}

@media print {
  body { background: #fff; }
  .drawer-toggle,
  .debug-button,
  .debug-panel,
  .contacts-footer,
  .contacts-actions,
  .gti-actions { display: none !important; }
  .desktop-topbar,
  .gti-body-block,
  .contacts-list-panel,
  .contacts-detail-panel {
    box-shadow: none;
    border-color: #bbb;
  }
}

/* Modes Simple / Avancé — compact, sans panneau dédié */
.contacts-view-toggle.compact {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px;
  border: 1px solid rgba(196,171,128,.38);
  border-radius: 999px;
  background: rgba(255,255,255,.72);
}
.contacts-view-toggle.compact .gti-btn {
  min-height: 30px;
  padding: 0 11px;
  font-size: 12px;
  border-radius: 999px;
}
.contacts-view-toggle .gti-btn.is-active { box-shadow: 0 0 0 2px rgba(8,121,130,.10); }
.contacts-advanced-panel {
  margin: 12px 0;
  border: 1px solid rgba(196,171,128,.35);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255,255,255,.72);
  text-align: left;
}
.contacts-advanced-panel h4 { margin: 0 0 4px; font-size: 16px; }
.contacts-advanced-panel p { margin: 0 0 8px; font-size: 13px; }
.contacts-advanced-panel pre {
  max-height: 220px;
  overflow: auto;
  margin: 0;
  padding: 10px;
  border-radius: 10px;
  background: #111820;
  color: #edf7f7;
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
body[data-contact-view="simple"] .advanced-only { display: none !important; }
body[data-contact-view="simple"] .contacts-detail-panel { min-height: 360px; }
body[data-contact-view="simple"] .contacts-detail { max-width: 560px; margin: 0 auto; }
body[data-contact-view="simple"] .gti-quick-grid.compact { grid-template-columns: repeat(2, minmax(0,1fr)); }
body[data-contact-view="advanced"] .contacts-detail-panel { min-height: 520px; }
body[data-contact-view="advanced"] .contacts-list { max-height: 62vh; }
@media (max-width: 980px) {
  .contacts-view-toggle.compact { justify-content: flex-start; width: max-content; }
}

.gti-fiche-head{margin-bottom:8px}.gti-kicker,.gti-body-intro,.txt p,[data-api-base-label]{display:none!important}.gti-body-title{font-size:22px}.contacts-command-panel{padding:8px;grid-template-columns:1fr 140px 140px auto}.contacts-list-panel,.contacts-detail-panel{min-height:260px;padding:10px}.contacts-layout{grid-template-columns:1.4fr .6fr}.contact-row{padding:6px 10px;border-radius:10px}.contact-avatar{display:none!important}.gti-quick-grid.compact{display:grid;grid-template-columns:1fr}.contacts-advanced-panel{margin-top:8px}.contacts-view-toggle.compact .gti-btn{min-height:28px;padding:0 10px;font-size:12px}.panel-title-row{margin-bottom:6px;padding-bottom:6px}

/* UX humaine V2.5 — sélecteur transverse ultra-compact
   Objectif: zéro scroll inutile, liste prioritaire, fiche courte, contrôles sur une seule ligne. */
.gti-production-page{padding:6px 8px;}
.desktop-topbar{min-height:40px;padding:6px 8px;border-radius:12px;box-shadow:none;}
.topbar-left{gap:8px;min-width:auto;}
.drawer-toggle{width:32px;height:32px;border-radius:10px;font-size:20px;line-height:1;}
.txt h1{font-size:22px;letter-spacing:-.03em;}
.topbar-status-pills{gap:6px;}
.status-pill{height:28px;padding:0 8px;gap:5px;font-size:12px;box-shadow:none;}
.pill-icon{width:18px;height:18px;font-size:10px;}
.pill-label{display:none;}
.gti-production-body{margin-top:6px;}
.gti-body-block{padding:8px 10px;border-radius:14px;box-shadow:none;}
.gti-fiche-head{margin:0 0 6px;min-height:0;align-items:center;}
.gti-body-title{display:none;}
.gti-head-badges{gap:6px;align-items:center;}
.contacts-view-toggle.compact{border:0;background:transparent;padding:0;gap:3px;}
.contacts-view-toggle.compact .gti-btn{min-height:24px;width:28px;padding:0;font-size:11px;border-radius:999px;}
.contacts-command-panel{padding:6px;border-radius:10px;grid-template-columns:minmax(260px,1fr) 116px 104px auto;gap:6px;align-items:center;}
.gti-field{gap:2px;}
.gti-field label{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;}
.gti-field input,.gti-field select{min-height:30px;border-radius:8px;padding:0 9px;font-size:13px;font-weight:700;}
.contacts-actions{gap:5px;flex-wrap:nowrap;}
.gti-btn{min-height:30px;padding:0 10px;border-radius:999px;font-size:12px;}
.gti-api-status{margin:6px 0;min-height:24px;padding:4px 8px;border-radius:9px;font-size:12px;}
.contacts-layout{grid-template-columns:minmax(420px,1fr) 360px;gap:8px;height:calc(100vh - 205px);min-height:330px;}
.contacts-list-panel,.contacts-detail-panel{min-height:0;height:100%;padding:8px;border-radius:12px;overflow:hidden;}
.panel-title-row{padding-bottom:5px;margin-bottom:5px;}
.panel-title-row h3{font-size:15px;}
.panel-title-row span{font-size:12px;}
.contacts-list{gap:5px;max-height:calc(100% - 28px);padding-right:3px;}
.contact-row{min-height:38px;padding:5px 8px;border-radius:9px;grid-template-columns:28px minmax(0,1fr) auto;gap:8px;}
.contact-mini-avatar{width:26px;height:26px;font-size:11px;}
.contact-main strong{font-size:13px;line-height:1.05;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.contact-main span{font-size:11px;margin-top:1px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.contact-flags{gap:2px;}
.contact-flag{font-size:10px;padding:2px 6px;}
.contacts-detail-panel{display:flex;flex-direction:column;}
.contacts-empty{min-height:120px;font-size:13px;}
.contacts-detail{display:flex;flex-direction:column;gap:6px;text-align:left;height:100%;}
.contacts-detail h4{font-size:17px;line-height:1.1;margin:0;}
.contacts-detail p{margin:0;color:var(--gti-muted);font-size:12px;}
.contact-avatar{display:none!important;}
.gti-quick-grid{gap:5px;margin:0;}
.gti-quick-grid.compact{grid-template-columns:1fr;}
.gti-quick-item{padding:5px 7px;border-radius:8px;display:grid;grid-template-columns:70px 1fr;gap:6px;align-items:center;}
.gti-quick-item span{font-size:10px;}
.gti-quick-item strong{font-size:12px;margin:0;}
.contacts-usage-help{display:none!important;}
.gti-actions.stack{gap:5px;margin-top:auto;}
.gti-actions.stack .gti-btn{width:100%;}
[data-action="copy-contact"]{display:none!important;}
.contacts-create-panel{margin:6px 0;padding:8px;border-radius:10px;}
.contacts-create-panel h3{font-size:15px;margin:0 0 6px;}
.gti-grid-2{gap:6px;grid-template-columns:repeat(3,minmax(0,1fr));}
.contacts-rule-note{display:none;}
.contacts-footer{display:none!important;}
.contacts-advanced-panel{margin:4px 0;padding:7px;border-radius:8px;}
.contacts-advanced-panel h4{font-size:13px;}
.contacts-advanced-panel p{display:none;}
.contacts-advanced-panel pre{max-height:120px;font-size:10px;padding:7px;}
body[data-contact-view="advanced"] .contacts-layout{height:calc(100vh - 205px);}
body[data-contact-view="advanced"] .contacts-detail-panel{min-height:0;}
body[data-contact-view="simple"] .contacts-detail-panel{min-height:0;}
body[data-contact-view="simple"] .contacts-detail{max-width:none;margin:0;}
@media (max-width:980px){
  .contacts-layout{grid-template-columns:1fr;height:auto;}
  .contacts-list-panel,.contacts-detail-panel{height:auto;}
  .contacts-list{max-height:none;}
  .contacts-command-panel{grid-template-columns:1fr 1fr;}
  .gti-grid-2{grid-template-columns:1fr;}
}

/* CONTACTS UX V2.6 — rééquilibrage liste/fiche + mode avancé utile
   Objectif : la liste ne doit plus écraser la fiche. En mode avancé,
   la fiche devient la zone principale et affiche davantage d'informations. */
.contacts-layout{
  grid-template-columns:minmax(520px,58%) minmax(430px,42%);
  gap:8px;
}
body[data-contact-view="advanced"] .contacts-layout{
  grid-template-columns:minmax(430px,46%) minmax(560px,54%);
}
body[data-contact-view="advanced"] .contacts-detail-panel{
  min-width:0;
}
body[data-contact-view="advanced"] .contacts-detail{
  gap:7px;
}
body[data-contact-view="advanced"] .gti-quick-grid.compact{
  grid-template-columns:repeat(2,minmax(0,1fr));
}
body[data-contact-view="advanced"] .gti-quick-item{
  min-height:38px;
}
body[data-contact-view="advanced"] .gti-quick-item strong{
  overflow-wrap:anywhere;
  word-break:break-word;
}
body[data-contact-view="advanced"] .contacts-advanced-panel{
  display:flex;
  flex-direction:column;
  min-height:0;
  flex:1 1 auto;
}
body[data-contact-view="advanced"] .contacts-advanced-panel h4{
  margin:0 0 4px;
}
body[data-contact-view="advanced"] .contacts-advanced-panel pre{
  max-height:none;
  min-height:150px;
  flex:1 1 auto;
  overflow:auto;
  white-space:pre-wrap;
}
body[data-contact-view="advanced"] .gti-actions.stack{
  margin-top:6px;
}
@media (min-width:1200px){
  body[data-contact-view="advanced"] .contacts-list-panel .panel-title-row h3::after{
    content:"";
  }
}
@media (max-width:980px){
  .contacts-layout,
  body[data-contact-view="advanced"] .contacts-layout{
    grid-template-columns:1fr;
  }
}

/* CONTACTS UX V2.7 — fiche extensible + séparateur draggable
   Objectif : régler la répartition liste/fiche sans créer deux UI ni toucher au bridge. */
.contacts-layout{
  --contacts-list-pct:36%;
  display:grid!important;
  grid-template-columns:minmax(260px,var(--contacts-list-pct)) 10px minmax(360px,calc(100% - var(--contacts-list-pct) - 10px))!important;
  gap:0!important;
  align-items:stretch;
  height:calc(100vh - 178px)!important;
  min-height:360px;
}
.contacts-list-panel,
.contacts-detail-panel{
  min-width:0;
  min-height:0!important;
  height:100%;
  overflow:hidden;
}
.contacts-list-panel{border-radius:12px 0 0 12px;}
.contacts-detail-panel{border-radius:0 12px 12px 0;}
.contacts-splitter{
  position:relative;
  height:100%;
  cursor:col-resize;
  background:linear-gradient(180deg, transparent, rgba(196,171,128,.28), transparent);
  border-top:1px solid var(--gti-border);
  border-bottom:1px solid var(--gti-border);
  touch-action:none;
}
.contacts-splitter::before{
  content:"";
  position:absolute;
  left:50%;top:50%;
  width:4px;height:36px;
  transform:translate(-50%,-50%);
  border-radius:99px;
  background:repeating-linear-gradient(to bottom, rgba(80,80,80,.48) 0 3px, transparent 3px 6px);
}
.contacts-splitter:hover,
body[data-user-resizing="true"] .contacts-splitter{background:rgba(8,121,130,.10);}
.detail-title-row{align-items:center;}
.detail-title-actions{display:inline-flex;align-items:center;gap:7px;margin-left:auto;}
.detail-expand-btn{
  width:28px;height:28px;border-radius:8px;border:1px solid var(--gti-border);
  background:#fff;color:var(--gti-primary-dark);font-weight:900;font-size:20px;line-height:1;
  cursor:pointer;display:inline-flex;align-items:center;justify-content:center;
}
.detail-expand-btn:hover{box-shadow:0 0 0 3px rgba(8,121,130,.10);}
body[data-detail-expanded="true"] .detail-expand-btn{background:#eef8f8;}
body[data-contact-view="simple"] .contacts-detail-panel .panel-title-row{margin-bottom:8px;}
body[data-contact-view="advanced"] .contacts-detail-panel .panel-title-row{margin-bottom:8px;}
body[data-detail-expanded="true"] .contacts-advanced-panel{display:flex!important;}
body[data-contact-view="advanced"] .contacts-detail{height:100%;}
body[data-contact-view="advanced"] .contacts-advanced-panel{min-height:130px;}
body[data-contact-view="advanced"] .contacts-advanced-panel pre{min-height:120px;}
body[data-detail-expanded="true"] .contacts-detail-panel{background:rgba(255,255,255,.88);}
body[data-detail-expanded="true"] .gti-quick-grid.compact{grid-template-columns:repeat(2,minmax(0,1fr));}
body[data-detail-expanded="true"] .contacts-list .contact-main span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
@media (max-width:980px){
  .contacts-layout{grid-template-columns:1fr!important;height:auto!important;}
  .contacts-splitter{display:none;}
  .contacts-list-panel,.contacts-detail-panel{border-radius:12px;height:auto;}
}

/* CONTACTS UX V2.8 — suppression zone vide fiche + ergonomie fiche avancée */
.contacts-empty[hidden],
[data-empty-detail][hidden]{
  display:none!important;
}
.contacts-detail-panel{
  display:flex;
  flex-direction:column;
}
.contacts-detail-panel .panel-title-row{
  flex:0 0 auto;
}
.contacts-detail{
  flex:1 1 auto;
  min-height:0;
  text-align:left!important;
  display:flex;
  flex-direction:column;
  gap:8px;
  padding:2px 0 0;
  overflow:auto;
}
.contacts-detail[hidden]{display:none!important;}
.contacts-detail .contact-avatar{display:none!important;}
.contacts-detail h4{
  margin:0!important;
  font-size:22px!important;
  line-height:1.1;
}
.contacts-detail [data-detail-meta]{
  margin:0!important;
  color:var(--gti-muted);
  font-weight:700;
}
.gti-quick-grid.compact{
  margin:4px 0!important;
  gap:6px!important;
  grid-template-columns:repeat(2,minmax(0,1fr))!important;
}
.gti-quick-item{
  padding:7px 9px!important;
  min-height:42px;
  display:grid;
  grid-template-columns:120px 1fr;
  align-items:center;
  gap:8px;
}
.gti-quick-item span{font-size:12px!important;}
.gti-quick-item strong{
  margin-top:0!important;
  font-size:14px!important;
  word-break:break-word;
  overflow-wrap:anywhere;
}
.contacts-usage-help{display:none!important;}
.contacts-advanced-panel{
  margin:2px 0 0!important;
  padding:7px!important;
  min-height:0!important;
  flex:1 1 auto;
  display:flex;
  flex-direction:column;
}
.contacts-advanced-panel h4{
  margin:0 0 6px!important;
  font-size:14px!important;
}
.contacts-advanced-panel pre{
  flex:1 1 auto;
  min-height:80px!important;
  max-height:none!important;
  margin:0!important;
}
.gti-actions.stack{
  flex:0 0 auto;
  margin-top:auto;
}
body[data-contact-view="simple"] .contacts-detail{
  justify-content:flex-start;
}
body[data-contact-view="simple"] .gti-quick-grid.compact{
  grid-template-columns:repeat(2,minmax(0,1fr))!important;
}
body[data-contact-view="simple"] .contacts-layout{
  --contacts-list-pct:42%;
}
body[data-contact-view="advanced"] .contacts-layout,
body[data-detail-expanded="true"] .contacts-layout{
  --contacts-list-pct:30%;
}
body[data-contact-view="advanced"] .contacts-detail-panel,
body[data-detail-expanded="true"] .contacts-detail-panel{
  min-height:0!important;
}
body[data-contact-view="advanced"] .contacts-detail,
body[data-detail-expanded="true"] .contacts-detail{
  gap:7px;
}
body[data-contact-view="advanced"] .contacts-advanced-panel,
body[data-detail-expanded="true"] .contacts-advanced-panel{
  display:flex!important;
}
@media (max-width:980px){
  .contacts-detail{overflow:visible;}
  .gti-quick-grid.compact{grid-template-columns:1fr!important;}
}

/* V2.9 — mode avancé métier : contexte locatif, pas JSON brut visible */
.contact-context-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:8px;
  min-height:0;
}
.contact-context-card{
  border:1px solid rgba(196,171,128,.35);
  border-radius:10px;
  background:rgba(255,255,255,.78);
  padding:8px 10px;
  min-height:58px;
}
.contact-context-card h5{
  margin:0 0 5px;
  font-size:13px;
  line-height:1.1;
  color:var(--gti-text);
}
.contact-context-wide{grid-column:1 / -1;}
.context-lines{
  display:grid;
  gap:3px;
  font-size:12px;
  line-height:1.25;
  color:#3d403f;
}
.context-muted{color:var(--gti-muted);font-style:italic;}
.contact-debug-raw{
  margin-top:8px;
  border:1px solid rgba(196,171,128,.28);
  border-radius:10px;
  background:rgba(255,255,255,.55);
  overflow:hidden;
}
.contact-debug-raw summary{
  cursor:pointer;
  padding:7px 10px;
  font-size:12px;
  font-weight:800;
  color:#52636a;
}
.contact-debug-raw pre{
  min-height:60px!important;
  max-height:150px!important;
  margin:0!important;
  border-radius:0!important;
}
body[data-contact-view="advanced"] .contacts-advanced-panel,
body[data-detail-expanded="true"] .contacts-advanced-panel{
  gap:8px;
}
body[data-contact-view="advanced"] .contacts-advanced-panel pre,
body[data-detail-expanded="true"] .contacts-advanced-panel pre{
  min-height:60px!important;
}
@media (max-width:980px){.contact-context-grid{grid-template-columns:1fr;}}

/* V2.16 — rendu humain du contexte locatif avancé */
body[data-contact-view="advanced"] .contacts-detail{
  overflow:auto;
  padding-right:4px;
}
body[data-contact-view="advanced"] .contacts-advanced-panel{
  margin-top:4px!important;
  padding:8px!important;
  border:1px solid rgba(196,171,128,.28);
  border-radius:12px;
  background:rgba(255,255,255,.55);
  flex:0 0 auto!important;
}
body[data-contact-view="advanced"] .contacts-advanced-panel > h4{
  margin:0 0 8px!important;
  font-size:15px!important;
  line-height:1.15;
}
body[data-contact-view="advanced"] .contact-context-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:8px;
}
body[data-contact-view="advanced"] .contact-context-card{
  min-height:0!important;
  padding:9px!important;
  border-radius:12px;
  background:#fff;
  box-shadow:0 1px 0 rgba(29,34,38,.03);
}
body[data-contact-view="advanced"] .contact-context-card h5{
  margin:0 0 6px!important;
  padding-bottom:4px;
  border-bottom:1px solid rgba(196,171,128,.22);
  font-size:13px!important;
}
.context-lines{
  display:grid!important;
  gap:6px!important;
  font-size:12px!important;
  line-height:1.25!important;
}
.context-line{
  padding:6px 8px;
  border:1px solid rgba(196,171,128,.22);
  border-radius:9px;
  background:rgba(250,248,242,.72);
}
.context-mini-card{
  display:grid;
  gap:4px;
  padding:7px 8px;
  border:1px solid rgba(8,121,130,.18);
  border-radius:10px;
  background:linear-gradient(180deg,rgba(255,255,255,.98),rgba(246,251,251,.94));
}
.context-mini-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
}
.context-mini-head strong{
  font-size:12px;
  line-height:1.15;
}
.context-mini-head span{
  flex:0 0 auto;
  padding:2px 7px;
  border-radius:999px;
  background:#eef6f6;
  color:#087982;
  font-size:10px;
  font-weight:900;
  white-space:nowrap;
}
.context-mini-main{
  font-size:12px;
  font-weight:900;
  color:#1d2226;
}
.context-mini-sub{
  font-size:11px;
  color:#5c676b;
  font-weight:700;
}
.context-muted{
  padding:6px 8px;
  border-radius:9px;
  background:rgba(245,244,240,.8);
  font-size:12px;
}
body[data-contact-view="advanced"] .gti-actions.stack{
  position:static!important;
  flex:0 0 auto!important;
  margin-top:8px!important;
  padding-top:8px;
  border-top:1px solid rgba(196,171,128,.24);
  background:transparent!important;
}
body[data-contact-view="advanced"] .gti-actions.stack .gti-btn.primary{
  min-height:34px;
}
body[data-contact-view="advanced"] .contact-debug-raw{
  margin-top:8px!important;
}
body[data-contact-view="advanced"] .contact-debug-raw:not([open]) pre{
  display:none!important;
}
@media (max-width:980px){
  body[data-contact-view="advanced"] .contact-context-grid{grid-template-columns:1fr;}
}
