:root{
  --teal-900:#0b4a3d;
  --teal-700:#0f6e5c;
  --teal-500:#16916f;
  --teal-100:#e7f5f0;
  --ink-900:#1c2321;
  --ink-600:#4b5a56;
  --ink-300:#8fa39d;
  --bg:#f5f8f7;
  --card:#ffffff;
  --border:#dbe6e2;
  --amber:#b5730a;
  --red:#b3261e;
  --radius:14px;
  --shadow: 0 2px 10px rgba(11,74,61,0.08);
}

*{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{
  font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","Segoe UI",Roboto,sans-serif;
  background:var(--bg);
  color:var(--ink-900);
  -webkit-tap-highlight-color:transparent;
}

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

.icon{width:16px; height:16px; vertical-align:-3px; margin-right:2px;}

/* Feedback tactile : léger enfoncement au press, plutôt qu'un simple changement de couleur */
.btn, .type-btn, .state-opt, .zone-ras-btn, .tab-btn{transition:transform .08s ease, background-color .15s ease, border-color .15s ease, box-shadow .15s ease;}
.btn:active, .type-btn:active, .state-opt:active, .zone-ras-btn:active{transform:scale(0.97);}

/* États de focus visibles (clavier externe iPad, accessibilité) */
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible{
  outline:2px solid var(--teal-500); outline-offset:2px;
}

/* Fondu léger à l'affichage d'une vue plutôt qu'un basculement sec */
@keyframes viewFadeIn{ from{opacity:0; transform:translateY(4px);} to{opacity:1; transform:translateY(0);} }
.view.active{animation:viewFadeIn .18s ease;}

#app{display:flex; flex-direction:column; min-height:100vh;}

.topbar{
  display:flex; align-items:center; gap:20px;
  padding:14px 24px;
  padding-top:calc(14px + env(safe-area-inset-top));
  padding-left:calc(24px + env(safe-area-inset-left));
  padding-right:calc(24px + env(safe-area-inset-right));
  background:var(--card);
  border-bottom:1px solid var(--border);
  position:sticky; top:0; z-index:20;
  flex-wrap:wrap;
}
.brand{display:flex; align-items:center; gap:10px;}
.brand-badge{
  width:40px; height:40px; border-radius:10px;
  background:var(--teal-700); color:#fff;
  display:flex; align-items:center; justify-content:center;
  font-weight:700; font-size:15px;
}
.brand-title{font-weight:700; font-size:16px;}
.brand-sub{font-size:12px; color:var(--ink-600);}

.tabs{display:flex; gap:6px; flex:1; flex-wrap:wrap;}
.tab-btn{
  border:none; background:transparent; padding:10px 16px;
  border-radius:999px; font-size:15px; color:var(--ink-600);
  cursor:pointer;
}
.tab-btn.active{background:var(--teal-100); color:var(--teal-900); font-weight:600;}

.role-switch{display:flex; align-items:center; gap:2px; padding:3px; background:var(--bg); border:1px solid var(--border); border-radius:999px;}
.role-btn{
  border:none; background:transparent; padding:9px 16px; border-radius:999px;
  font-size:13px; font-weight:600; color:var(--ink-600); cursor:pointer;
}
.role-btn.active[data-role="proprietaire"]{background:var(--teal-700); color:#fff;}
.role-btn.active[data-role="conciergerie"]{background:var(--amber); color:#fff;}

.abritel-badge{
  display:inline-flex; align-items:center; gap:6px; font-size:12px; font-weight:600;
  padding:5px 12px; border-radius:999px; margin-bottom:14px; background:var(--teal-100); color:var(--ink-600);
}
.abritel-badge .conn-dot{width:8px; height:8px;}

.conn-status{display:flex; align-items:center; gap:12px; padding:12px 14px; border-radius:10px; background:var(--bg); margin-bottom:10px; flex-wrap:wrap;}
.conn-status-text{flex:1; min-width:160px; font-weight:600; font-size:13px;}
.conn-dot{width:10px; height:10px; border-radius:50%; flex-shrink:0;}
.conn-dot-off{background:var(--ink-300);}
.conn-dot-ok{background:var(--teal-500);}
.conn-dot-error{background:var(--red);}

main#views{
  flex:1; padding:20px 24px 60px; max-width:1100px; width:100%; margin:0 auto;
  padding-bottom:calc(60px + env(safe-area-inset-bottom));
  padding-left:calc(24px + env(safe-area-inset-left));
  padding-right:calc(24px + env(safe-area-inset-right));
}

.view{display:none;}
.view.active{display:block;}

.view-header{display:flex; align-items:center; justify-content:space-between; margin-bottom:18px;}
.view-header h1{font-size:22px; margin:0;}

.section-title{font-size:16px; font-weight:700; margin:28px 0 12px; color:var(--teal-900);}

.notice{padding:12px 16px; border-radius:10px; margin-bottom:16px; font-size:14px;}
.notice-info{background:#eef4ff; color:#1d4ed8;}
.notice-warn{background:#fff6e5; color:var(--amber);}
.notice-error{background:#fdeceb; color:var(--red);}

.grid-cards{display:grid; grid-template-columns:repeat(auto-fit,minmax(200px,1fr)); gap:14px;}
.card{background:var(--card); border:1px solid var(--border); border-radius:var(--radius); padding:16px; box-shadow:var(--shadow);}
.card-label{font-size:12px; color:var(--ink-600); text-transform:uppercase; letter-spacing:.03em;}
.card-value{font-size:22px; font-weight:700; margin-top:6px; color:var(--teal-900);}
.card-sub{font-size:12px; color:var(--ink-300); margin-top:2px;}

.stay-list{display:flex; flex-direction:column; gap:10px; margin-bottom:20px;}
.stay-item{
  background:var(--card); border:1px solid var(--border); border-radius:var(--radius);
  padding:14px 16px; display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap;
}
.stay-main{display:flex; flex-direction:column; gap:2px;}
.stay-tenant{font-weight:700;}
.stay-dates{font-size:13px; color:var(--ink-600);}
.stay-badges{display:flex; gap:6px; flex-wrap:wrap;}
.badge{font-size:11px; padding:4px 9px; border-radius:999px; font-weight:600;}
.badge-pending{background:#fff6e5; color:var(--amber);}
.badge-done{background:var(--teal-100); color:var(--teal-900);}
.badge-diff{background:#fdeceb; color:var(--red);}
.badge-source{background:#eef4ff; color:#1d4ed8;}
.badge-note{background:#f3eaff; color:#7c3aed;}

.stay-delete{
  background:none; border:1px solid var(--border); color:var(--ink-300); border-radius:999px;
  width:22px; height:22px; line-height:1; cursor:pointer; font-size:12px;
}
.stay-delete:hover, .stay-delete:active{color:var(--red); border-color:var(--red);}

.stay-item-blocked{opacity:.6; background:var(--bg); box-shadow:none;}
.stay-item-blocked .stay-tenant{font-weight:600; color:var(--ink-600);}
.section-title-sub{font-size:13px; font-weight:700; margin:18px 0 8px; color:var(--ink-600); text-transform:uppercase; letter-spacing:.03em;}

.btn{border:none; border-radius:10px; padding:12px 18px; font-size:15px; font-weight:600; cursor:pointer;}
.btn-primary{background:var(--teal-700); color:#fff;}
.btn-primary:active{background:var(--teal-900);}
.btn-ghost{background:transparent; color:var(--teal-900); border:1px solid var(--border);}
.btn-danger{background:#fdeceb; color:var(--red);}
.btn-block{width:100%; display:block; text-align:center;}

.picker-block{background:var(--card); border:1px solid var(--border); border-radius:var(--radius); padding:20px; display:flex; flex-direction:column; gap:12px; max-width:520px;}
.picker-block select{padding:12px; border-radius:10px; border:1px solid var(--border); font-size:15px;}

.empty-state-actions{display:flex; gap:8px; margin-top:12px;}

.notes-panel{border-top:1px solid var(--border); border-bottom:1px solid var(--border); padding:14px 0; margin:4px 0;}
.notes-panel h3{margin:0 0 6px; font-size:14px; color:var(--teal-900);}
.notes-panel textarea{
  width:100%; padding:10px 12px; border-radius:8px; border:1px solid var(--border);
  font-size:14px; font-family:inherit; resize:vertical; min-height:64px; margin-top:6px;
}

.type-toggle{display:flex; gap:8px;}
.type-btn{flex:1; padding:12px; border-radius:10px; border:1px solid var(--border); background:#fff; font-weight:600; cursor:pointer;}
.type-btn.active{background:var(--teal-700); color:#fff; border-color:var(--teal-700);}

.checklist-head{display:flex; justify-content:space-between; align-items:flex-end; flex-wrap:wrap; gap:14px; margin-bottom:14px;}
.checklist-title{font-size:20px; font-weight:700;}
.checklist-meta{font-size:13px; color:var(--ink-600);}
.progress-wrap{min-width:200px;}
.progress-bar{width:220px; height:8px; background:var(--border); border-radius:99px; overflow:hidden;}
.progress-fill{height:100%; background:var(--teal-500); width:0%; transition:width .2s;}
.progress-label{font-size:12px; color:var(--ink-600); margin-top:4px; text-align:right;}

.zone-card{background:var(--card); border:1px solid var(--border); border-radius:var(--radius); margin-bottom:14px; overflow:hidden; box-shadow:var(--shadow);}
.zone-header{padding:14px 18px; display:flex; justify-content:space-between; align-items:center; cursor:pointer; background:var(--teal-100); flex-wrap:wrap; gap:8px;}
.zone-header h3{margin:0; font-size:15px; color:var(--teal-900);}
.zone-header-actions{display:flex; align-items:center; gap:10px;}
.zone-progress{font-size:12px; color:var(--teal-700); font-weight:600; min-width:34px; text-align:right;}
.zone-ras-btn{
  display:flex; align-items:center; gap:4px; padding:6px 10px; border-radius:8px;
  border:1px solid var(--teal-500); background:#fff; color:var(--teal-700);
  font-size:12px; font-weight:600; cursor:pointer;
}
.zone-ras-btn:active{background:var(--teal-100);}
.zone-ras-btn .icon{width:13px; height:13px; margin-right:0;}
.zone-body{padding:6px 18px 14px;}
.zone-body.collapsed{display:none;}

.element-row{padding:12px 0; border-top:1px solid var(--border);}
.element-row:first-child{border-top:none;}
.element-name{font-weight:600; font-size:14px; margin-bottom:8px;}
.state-options{display:flex; gap:8px; flex-wrap:wrap; margin-bottom:8px;}
.state-opt{padding:9px 14px; border-radius:999px; border:1px solid var(--border); background:#fff; font-size:13px; cursor:pointer;}
.state-opt[data-state="neuf"].selected{background:#e7f5f0; border-color:var(--teal-500); color:var(--teal-900);}
.state-opt[data-state="usage"].selected{background:#fff6e5; border-color:var(--amber); color:var(--amber);}
.state-opt[data-state="mauvais"].selected{background:#fdeceb; border-color:var(--red); color:var(--red);}
.element-remark{width:100%; padding:9px 12px; border-radius:8px; border:1px solid var(--border); font-size:13px; margin-bottom:8px; resize:none; overflow:hidden; min-height:38px;}
.element-actions{display:flex; align-items:center; gap:10px;}
.photo-btn{padding:8px 12px; border-radius:8px; border:1px dashed var(--teal-500); background:#fff; color:var(--teal-700); font-size:13px; cursor:pointer;}
.photo-count{font-size:12px; color:var(--ink-600);}

.signature-block{background:var(--card); border:1px solid var(--border); border-radius:var(--radius); padding:18px; margin-top:20px;}
.hint{font-size:13px; color:var(--ink-600); margin:4px 0 10px;}
#sigCanvas{width:100%; max-width:600px; height:180px; border:1px dashed var(--border); border-radius:10px; touch-action:none; background:#fff;}
.sig-actions{margin-top:8px;}

.editor-actions{display:flex; justify-content:space-between; margin-top:20px; gap:10px;}

.settings-block{background:var(--card); border:1px solid var(--border); border-radius:var(--radius); padding:18px; margin-bottom:16px; max-width:640px;}
.settings-block label{display:block; font-size:13px; font-weight:600; margin:10px 0 4px;}
.settings-block input[type="text"], .settings-block input[type="date"]{
  width:100%; padding:11px 12px; border-radius:8px; border:1px solid var(--border); font-size:14px;
}
.checkbox-line{display:flex; align-items:center; gap:8px; font-weight:500; font-size:14px;}
.staff-add{display:flex; gap:8px; margin-top:10px; flex-wrap:wrap;}
.staff-add input{flex:1; min-width:140px; padding:10px; border-radius:8px; border:1px solid var(--border);}
.staff-row{display:flex; justify-content:space-between; align-items:center; padding:8px 0; border-top:1px solid var(--border); font-size:14px;}
.staff-row:first-child{border-top:none;}
.staff-remove{background:none; border:none; color:var(--red); cursor:pointer; font-size:13px;}

.modal-overlay{
  position:fixed; inset:0; background:rgba(17,26,24,.45); display:flex; align-items:center; justify-content:center; z-index:100; padding:20px;
}
.modal{background:#fff; border-radius:16px; padding:22px; width:100%; max-width:420px;}
.modal h2{margin-top:0;}
.modal label{display:block; font-size:13px; font-weight:600; margin:10px 0 4px;}
.modal input{width:100%; padding:11px 12px; border-radius:8px; border:1px solid var(--border); font-size:14px;}
.modal-actions{display:flex; justify-content:flex-end; gap:10px; margin-top:18px;}
.modal-photo{max-width:480px;}
.photo-thumbs{display:flex; gap:8px; flex-wrap:wrap; margin:14px 0;}
.photo-thumbs img{width:80px; height:80px; object-fit:cover; border-radius:8px; border:1px solid var(--border);}
.photo-input-label{margin-bottom:10px;}

.occupants-panel{border-top:1px solid var(--border); border-bottom:1px solid var(--border); padding:14px 0; margin:4px 0;}
.occupants-head{display:flex; justify-content:space-between; align-items:center; gap:10px; flex-wrap:wrap;}
.occupants-head h3{margin:0; font-size:14px; color:var(--teal-900);}
.occupants-list{display:flex; flex-direction:column; gap:8px; margin-top:10px;}
.occupant-row{display:flex; align-items:center; gap:10px; padding:8px 10px; background:var(--bg); border-radius:8px;}
.occupant-thumb{width:36px; height:36px; border-radius:6px; object-fit:cover; border:1px solid var(--border); flex-shrink:0;}
.occupant-thumb-placeholder{width:36px; height:36px; border-radius:6px; background:var(--teal-100); flex-shrink:0;}
.occupant-name{flex:1; font-weight:600; font-size:14px;}
.occupant-contact{font-weight:400; color:var(--ink-600); font-size:12px;}
.occupant-nodoc{font-size:11px; color:var(--amber); font-weight:600;}
.occupant-remove{background:none; border:none; color:var(--red); cursor:pointer; font-size:13px;}
.occ-id-thumb{margin:8px 0;}
.occ-id-thumb img{width:100%; max-width:320px; border-radius:8px; border:1px solid var(--border); display:block;}

.btn:disabled{opacity:.45; cursor:not-allowed;}
.btn:disabled:active{transform:none;}

/* Comme .btn:disabled visuellement, mais reste cliquable : le clic doit toujours
   produire un message clair plutôt qu'un bouton mort qui ne fait rien. */
.btn-needs-attention{opacity:.55;}

.compare-item{background:var(--card); border:1px solid var(--border); border-radius:var(--radius); padding:16px; margin-bottom:12px;}
.compare-item.has-diff{border-color:var(--red);}
.compare-title{font-weight:700; margin-bottom:8px;}
.compare-cols{display:grid; grid-template-columns:1fr 1fr; gap:14px;}
.compare-col h4{margin:0 0 6px; font-size:13px; color:var(--ink-600);}
.compare-col img{width:100%; border-radius:8px; margin-top:6px;}

.toast{
  position:fixed; bottom:24px; left:50%; transform:translateX(-50%) translateY(20px);
  background:var(--ink-900); color:#fff; padding:12px 20px; border-radius:10px;
  font-size:14px; opacity:0; pointer-events:none; transition:all .25s; z-index:200;
}
.toast.show{opacity:1; transform:translateX(-50%) translateY(0);}

@media (max-width:640px){
  .topbar{padding:10px 14px;}
  main#views{padding:14px 14px 50px;}
  .compare-cols{grid-template-columns:1fr;}
}
