/* ============================================================
   MAISON CARRINGTON — Design system
   ============================================================ */

:root{
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-sans: 'Manrope', system-ui, -apple-system, sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --sidebar-w: 272px;
  --topbar-h: 68px;
}

/* ---------- Dark theme (default) ---------- */
[data-theme="dark"]{
  color-scheme: dark;
  --bg: #0a0906;
  --bg-alt: #110e08;
  --surface: #17130c;
  --surface-2: #1e1810;
  --surface-hover: #241d13;
  --border: #332a19;
  --border-soft: #241d13;
  --text: #f3ead7;
  --text-dim: #b9ab8a;
  --text-faint: #7d715a;
  --gold: #d4af37;
  --gold-soft: rgba(212,175,55,.14);
  --gold-dark: #a5811f;
  --gold-light: #f1d580;
  --danger: #e2685f;
  --danger-soft: rgba(226,104,95,.15);
  --success: #4fbb85;
  --success-soft: rgba(79,187,133,.15);
  --warning: #e0a75d;
  --warning-soft: rgba(224,167,93,.15);
  --info: #6ba4e0;
  --info-soft: rgba(107,164,224,.15);
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --overlay: rgba(0,0,0,.6);
}

/* ---------- Light theme ---------- */
[data-theme="light"]{
  color-scheme: light;
  --bg: #f6f2ea;
  --bg-alt: #efe8d8;
  --surface: #ffffff;
  --surface-2: #faf6ec;
  --surface-hover: #f1ead9;
  --border: #e3d8ba;
  --border-soft: #ece3cb;
  --text: #241f10;
  --text-dim: #665d3f;
  --text-faint: #948a68;
  --gold: #a5791f;
  --gold-soft: rgba(165,121,31,.12);
  --gold-dark: #7d5c17;
  --gold-light: #c99a34;
  --danger: #c8433b;
  --danger-soft: rgba(200,67,59,.1);
  --success: #2f8f5f;
  --success-soft: rgba(47,143,95,.1);
  --warning: #b8791f;
  --warning-soft: rgba(184,121,31,.12);
  --info: #2f6fb8;
  --info-soft: rgba(47,111,184,.1);
  --shadow: 0 10px 30px rgba(60,45,10,.12);
  --overlay: rgba(30,24,10,.45);
}

[hidden]{display:none !important;}
*{box-sizing:border-box;}
html,body{height:100%;}
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family:var(--font-sans);
  -webkit-font-smoothing:antialiased;
  transition:background .25s ease,color .25s ease;
}
h1,h2,h3,h4{font-family:var(--font-serif); margin:0; font-weight:700;}
p{margin:0;}
a{color:inherit;}
button{font-family:inherit;}
::selection{background:var(--gold-soft);}

::-webkit-scrollbar{width:10px; height:10px;}
::-webkit-scrollbar-track{background:transparent;}
::-webkit-scrollbar-thumb{background:var(--border); border-radius:10px;}
::-webkit-scrollbar-thumb:hover{background:var(--gold-dark);}

/* ============================================================
   Boutons / champs / éléments communs
   ============================================================ */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  padding:11px 18px; border-radius:var(--radius-sm); border:1px solid transparent;
  font-size:14px; font-weight:700; cursor:pointer; transition:.15s ease; white-space:nowrap;
  font-family:var(--font-sans);
}
.btn:active{transform:translateY(1px);}
.btn-gold{ background:linear-gradient(135deg,var(--gold-light),var(--gold-dark)); color:#1a1405; box-shadow:0 6px 18px var(--gold-soft);}
.btn-gold:hover{filter:brightness(1.08);}
.btn-outline{ background:transparent; border-color:var(--border); color:var(--text);}
.btn-outline:hover{ background:var(--surface-hover); border-color:var(--gold-dark);}
.btn-ghost{ background:var(--surface-2); border-color:var(--border); color:var(--text);}
.btn-ghost:hover{ background:var(--surface-hover);}
.btn-danger{ background:var(--danger-soft); color:var(--danger); border-color:transparent;}
.btn-danger:hover{filter:brightness(1.1);}
.btn-sm{padding:7px 12px; font-size:12.5px; border-radius:7px;}
.btn-block{width:100%;}
.btn:disabled{opacity:.5; cursor:not-allowed;}
.link-btn{background:none; border:none; color:var(--gold); font-weight:700; cursor:pointer; font-size:12.5px; padding:0;}

.icon-btn{
  width:40px; height:40px; border-radius:50%; border:1px solid var(--border); background:var(--surface-2);
  color:var(--text); display:flex; align-items:center; justify-content:center; cursor:pointer; font-size:17px;
  transition:.15s ease; position:relative; flex-shrink:0;
}
.icon-btn:hover{ background:var(--surface-hover); border-color:var(--gold-dark);}

.field{ display:flex; flex-direction:column; gap:6px; font-size:13px; color:var(--text-dim); font-weight:600;}
.field input, .field select, .field textarea, select.field{
  font-family:var(--font-sans);
  background:var(--surface-2); border:1px solid var(--border); color:var(--text);
  border-radius:var(--radius-sm); padding:11px 13px; font-size:14px; outline:none; transition:.15s ease;
  width:100%;
}
.field input:focus, .field select:focus, .field textarea:focus, select.field:focus{ border-color:var(--gold); box-shadow:0 0 0 3px var(--gold-soft);}
.field textarea{resize:vertical; min-height:80px; font-family:var(--font-sans);}
.field select, select.field{
  appearance:none; -webkit-appearance:none; -moz-appearance:none;
  padding-right:34px; cursor:pointer;
  background-repeat:no-repeat; background-position:right 12px center; background-size:13px;
}
[data-theme="dark"] .field select, [data-theme="dark"] select.field{
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'><path d='M5 8l5 5 5-5' stroke='%23b9ab8a' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}
[data-theme="light"] .field select, [data-theme="light"] select.field{
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'><path d='M5 8l5 5 5-5' stroke='%23665d3f' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}
.field select:hover, select.field:hover{ border-color:var(--gold-dark); }
.field select option, select.field option{ background:var(--surface); color:var(--text); }

.field input[type="date"], .field input[type="time"], .field input[type="datetime-local"]{ cursor:pointer; }
.field input[type="date"]::-webkit-calendar-picker-indicator,
.field input[type="time"]::-webkit-calendar-picker-indicator,
.field input[type="datetime-local"]::-webkit-calendar-picker-indicator{
  cursor:pointer; border-radius:6px; padding:4px; margin-right:-4px; opacity:.8; transition:.15s ease;
}
.field input[type="date"]::-webkit-calendar-picker-indicator:hover,
.field input[type="time"]::-webkit-calendar-picker-indicator:hover,
.field input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover{
  opacity:1; background:var(--gold-soft);
}
[data-theme="dark"] .field input[type="date"]::-webkit-calendar-picker-indicator,
[data-theme="dark"] .field input[type="time"]::-webkit-calendar-picker-indicator,
[data-theme="dark"] .field input[type="datetime-local"]::-webkit-calendar-picker-indicator{
  filter:invert(1) brightness(1.6) sepia(1) saturate(2) hue-rotate(5deg);
}
.form-grid{display:grid; grid-template-columns:1fr 1fr; gap:14px;}
.form-grid .full{grid-column:1/-1;}
@media (max-width:640px){ .form-grid{grid-template-columns:1fr;} }

.badge{
  display:inline-flex; align-items:center; gap:5px; padding:4px 10px; border-radius:100px;
  font-size:11.5px; font-weight:800; letter-spacing:.02em; text-transform:uppercase;
}
.badge-gold{background:var(--gold-soft); color:var(--gold);}
.badge-success{background:var(--success-soft); color:var(--success);}
.badge-danger{background:var(--danger-soft); color:var(--danger);}
.badge-warning{background:var(--warning-soft); color:var(--warning);}
.badge-info{background:var(--info-soft); color:var(--info);}
.badge-muted{background:var(--surface-2); color:var(--text-faint); border:1px solid var(--border);}

.card{
  background:var(--surface); border:1px solid var(--border-soft); border-radius:var(--radius-md);
  padding:20px; box-shadow:var(--shadow);
}
.card-flat{background:var(--surface); border:1px solid var(--border-soft); border-radius:var(--radius-md); padding:18px;}

.section-head{display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; margin-bottom:16px;}
.section-head h3{font-size:19px;}
.section-sub{color:var(--text-dim); font-size:13px; margin-top:3px;}

.empty-state{ text-align:center; padding:50px 20px; color:var(--text-faint);}
.empty-state .emoji{font-size:38px; display:block; margin-bottom:10px;}

.tag-row{display:flex; gap:8px; flex-wrap:wrap; align-items:center;}
.tag-row select.field, .tag-row .field select{ width:auto; flex:0 0 auto; }

.avatar{
  width:42px; height:42px; border-radius:50%; background:linear-gradient(135deg,var(--gold-light),var(--gold-dark));
  color:#1a1405; display:flex; align-items:center; justify-content:center; font-weight:800; font-size:14px; flex-shrink:0;
}
.avatar.sm{width:30px; height:30px; font-size:11px;}

/* Tabs (sous-onglets) */
.subtabs{display:flex; gap:6px; border-bottom:1px solid var(--border-soft); margin-bottom:18px; flex-wrap:wrap;}
.subtab-btn{
  background:none; border:none; padding:11px 16px; font-weight:700; color:var(--text-dim); cursor:pointer;
  border-bottom:2px solid transparent; font-size:13.5px; margin-bottom:-1px;
}
.subtab-btn.active{color:var(--gold); border-bottom-color:var(--gold);}

/* Table */
.table-wrap{overflow-x:auto; border-radius:var(--radius-md); border:1px solid var(--border-soft);}
table.data-table{width:100%; border-collapse:collapse; font-size:13.5px; min-width:640px;}
table.data-table thead th{
  text-align:left; padding:12px 14px; background:var(--surface-2); color:var(--text-faint);
  font-size:11px; text-transform:uppercase; letter-spacing:.05em; font-weight:800; border-bottom:1px solid var(--border-soft);
  white-space:nowrap;
}
table.data-table tbody td{padding:13px 14px; border-bottom:1px solid var(--border-soft); background:var(--surface); vertical-align:middle;}
table.data-table tbody tr:last-child td{border-bottom:none;}
table.data-table tbody tr:hover td{background:var(--surface-hover);}
.row-actions{display:flex; gap:6px; justify-content:flex-end;}

/* Grid de cartes KPI */
.kpi-grid{display:grid; grid-template-columns:repeat(4,1fr); gap:16px; margin-bottom:22px;}
@media (max-width:1000px){ .kpi-grid{grid-template-columns:repeat(2,1fr);} }
@media (max-width:560px){ .kpi-grid{grid-template-columns:1fr;} }
.kpi-card{
  background:var(--surface); border:1px solid var(--border-soft); border-radius:var(--radius-md); padding:18px;
  display:flex; flex-direction:column; gap:6px; position:relative; overflow:hidden;
}
.kpi-card::before{content:""; position:absolute; top:0; left:0; right:0; height:3px; background:linear-gradient(90deg,var(--gold-light),var(--gold-dark));}
.kpi-label{font-size:12px; color:var(--text-faint); font-weight:700; text-transform:uppercase; letter-spacing:.04em;}
.kpi-value{font-size:26px; font-weight:800; font-family:var(--font-serif);}
.kpi-sub{font-size:12px; color:var(--text-dim);}

.grid-2{display:grid; grid-template-columns:1.3fr 1fr; gap:18px;}
@media (max-width:900px){ .grid-2{grid-template-columns:1fr;} }
.grid-3{display:grid; grid-template-columns:repeat(3,1fr); gap:18px;}
@media (max-width:900px){ .grid-3{grid-template-columns:1fr;} }

.list-item{
  display:flex; align-items:center; gap:12px; padding:12px; border-radius:var(--radius-sm);
  border:1px solid var(--border-soft); background:var(--surface-2); margin-bottom:8px;
}
.list-item:last-child{margin-bottom:0;}
.list-item-body{flex:1; min-width:0;}
.list-item-title{font-weight:700; font-size:13.5px;}
.list-item-sub{font-size:12px; color:var(--text-dim); margin-top:2px;}
.list-item-time{font-size:11px; color:var(--text-faint); white-space:nowrap;}

/* ============================================================
   Ecran de connexion
   ============================================================ */
.login-screen{
  min-height:100vh; display:flex; align-items:center; justify-content:center; position:relative;
  background:radial-gradient(circle at 20% 20%, var(--bg-alt), var(--bg) 60%); padding:24px;
  padding-top:calc(24px + env(safe-area-inset-top,0px)); padding-bottom:calc(24px + env(safe-area-inset-bottom,0px));
}
.login-bg-deco{
  position:absolute; inset:0; pointer-events:none;
  background:
    radial-gradient(600px circle at 85% 15%, var(--gold-soft), transparent 60%),
    radial-gradient(500px circle at 10% 90%, var(--gold-soft), transparent 60%);
}
.login-card{
  position:relative; width:100%; max-width:420px; background:var(--surface); border:1px solid var(--border-soft);
  border-radius:var(--radius-lg); padding:38px 32px 30px; box-shadow:var(--shadow); text-align:center;
  transition:max-width .2s ease;
}
.login-card.wide{max-width:600px;}
.login-logo{width:96px; height:96px; object-fit:contain; margin-bottom:14px;}
.login-title{font-size:26px; letter-spacing:.02em;}
.login-slogan{color:var(--text-dim); font-size:13px; margin-top:6px; margin-bottom:26px; display:block;}
.login-form{display:flex; flex-direction:column; gap:14px; text-align:left;}
.login-error{color:var(--danger); font-size:12.5px; font-weight:700; background:var(--danger-soft); padding:8px 12px; border-radius:8px;}
.login-switch{margin-top:18px; font-size:12.5px; color:var(--text-dim);}
.theme-toggle-floating{
  position:fixed; top:20px; right:20px; width:44px; height:44px; border-radius:50%; border:1px solid var(--border);
  background:var(--surface); color:var(--text); font-size:18px; cursor:pointer;
  top:calc(20px + env(safe-area-inset-top,0px));
}

/* ============================================================
   App layout
   ============================================================ */
.app{display:flex; min-height:100vh;}
.sidebar{
  width:var(--sidebar-w); flex-shrink:0; background:var(--surface); border-right:1px solid var(--border-soft);
  display:flex; flex-direction:column; position:fixed; top:0; bottom:0; left:0; z-index:40;
  transition:transform .25s ease; padding-top:env(safe-area-inset-top,0px); padding-bottom:env(safe-area-inset-bottom,0px);
}
.sidebar-brand{display:flex; align-items:center; gap:10px; padding:18px 16px; border-bottom:1px solid var(--border-soft);}
.sidebar-brand img{width:38px; height:38px; object-fit:contain; flex-shrink:0;}
.sidebar-brand-text{display:flex; flex-direction:column; min-width:0; flex:1;}
.sidebar-brand-text strong{font-family:var(--font-serif); font-size:14.5px; line-height:1.2; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.role-badge{font-size:10.5px; color:var(--gold); font-weight:800; text-transform:uppercase; letter-spacing:.04em; margin-top:2px;}
.sidebar-close-btn{display:none; width:32px; height:32px; font-size:14px;}
.sidebar-nav{flex:1; overflow-y:auto; padding:14px 12px; display:flex; flex-direction:column; gap:3px;}
.nav-link{
  display:flex; align-items:center; gap:11px; padding:11px 12px; border-radius:10px; color:var(--text-dim);
  text-decoration:none; font-weight:700; font-size:13.5px; cursor:pointer; border:1px solid transparent; position:relative;
}
.nav-link:hover{background:var(--surface-hover); color:var(--text);}
.nav-link.active{background:var(--gold-soft); color:var(--gold); border-color:var(--gold-soft);}
.nav-link .nav-emoji{font-size:16px; width:20px; text-align:center;}
.nav-dot{width:8px; height:8px; border-radius:50%; background:var(--danger); margin-left:auto; box-shadow:0 0 0 2px var(--surface);}
.nav-count{margin-left:auto; background:var(--gold); color:#1a1405; font-size:10.5px; font-weight:800; padding:2px 7px; border-radius:100px;}
.nav-section-label{font-size:10.5px; text-transform:uppercase; letter-spacing:.06em; color:var(--text-faint); font-weight:800; padding:14px 12px 6px;}
.sidebar-footer{padding:14px 16px; border-top:1px solid var(--border-soft); display:flex; flex-direction:column; gap:12px;}
.sidebar-user{display:flex; align-items:center; gap:10px;}
.sidebar-user-info{display:flex; flex-direction:column; min-width:0;}
.sidebar-user-info strong{font-size:13px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.sidebar-user-info span{font-size:11.5px; color:var(--text-faint);}
.sidebar-overlay{display:none; position:fixed; inset:0; background:var(--overlay); z-index:35;}

.app-main{flex:1; margin-left:var(--sidebar-w); display:flex; flex-direction:column; min-height:100vh;}
.topbar{
  height:var(--topbar-h); flex-shrink:0; display:flex; align-items:center; gap:14px; padding:0 22px;
  border-bottom:1px solid var(--border-soft); background:var(--bg); position:sticky; top:0; z-index:20;
  padding-top:env(safe-area-inset-top,0px);
}
#btn-menu{display:none;}
.view-title{font-size:20px; flex:0 1 auto; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.topbar-actions{display:flex; align-items:center; gap:10px; margin-left:auto;}

.topbar-search{position:relative; flex:1 1 260px; max-width:340px; min-width:0;}
.topbar-search input{
  width:100%; background:var(--surface-2); border:1px solid var(--border); color:var(--text);
  border-radius:100px; padding:9px 16px; font-size:13px; outline:none; transition:.15s ease; font-family:var(--font-sans);
}
.topbar-search input:focus{border-color:var(--gold); box-shadow:0 0 0 3px var(--gold-soft);}
.global-search-results{
  position:absolute; top:calc(100% + 8px); left:0; right:0; max-height:70vh; overflow-y:auto;
  background:var(--surface); border:1px solid var(--border-soft); border-radius:var(--radius-md); box-shadow:var(--shadow); z-index:50; padding:8px;
}
.gsr-group-label{font-size:10.5px; text-transform:uppercase; letter-spacing:.05em; color:var(--text-faint); font-weight:800; padding:8px 10px 4px;}
.gsr-item{display:flex; align-items:center; gap:10px; padding:9px 10px; border-radius:8px; cursor:pointer;}
.gsr-item:hover{background:var(--surface-hover);}
@media (max-width:640px){ .topbar-search{display:none;} }

.notif-wrap{position:relative;}
.notif-count{
  position:absolute; top:-3px; right:-3px; background:var(--danger); color:#fff; font-size:10px; font-weight:800;
  min-width:17px; height:17px; border-radius:100px; display:flex; align-items:center; justify-content:center; padding:0 4px;
  border:2px solid var(--bg);
}
.notif-panel{
  position:absolute; top:52px; right:0; width:340px; max-width:88vw; max-height:70vh; overflow-y:auto;
  background:var(--surface); border:1px solid var(--border-soft); border-radius:var(--radius-md); box-shadow:var(--shadow); z-index:50;
}
.notif-panel-head{display:flex; align-items:center; justify-content:space-between; padding:14px 16px; border-bottom:1px solid var(--border-soft); position:sticky; top:0; background:var(--surface);}
.notif-list{padding:8px;}
.notif-item{display:flex; gap:10px; padding:11px 10px; border-radius:10px; cursor:pointer; align-items:flex-start;}
.notif-item:hover{background:var(--surface-hover);}
.notif-item.unread{background:var(--gold-soft);}
.notif-item .dot{width:8px; height:8px; border-radius:50%; background:var(--gold); margin-top:6px; flex-shrink:0;}
.notif-item .dot.read{background:transparent;}
.notif-item-text{font-size:12.5px; line-height:1.4;}
.notif-item-time{font-size:10.5px; color:var(--text-faint); margin-top:3px;}

.view-root{flex:1; padding:22px 26px 60px; max-width:1400px; width:100%; margin:0 auto;}
@media (max-width:768px){ .view-root{padding:16px 14px 50px;} }

/* Sidebar responsive */
@media (max-width:980px){
  .sidebar{transform:translateX(-100%);}
  .sidebar.open{transform:translateX(0); box-shadow:0 0 40px rgba(0,0,0,.4);}
  .sidebar-close-btn{display:flex;}
  .app-main{margin-left:0;}
  #btn-menu{display:flex;}
  .sidebar-overlay.show{display:block;}
}

/* ============================================================
   Modal
   ============================================================ */
.modal-backdrop{
  position:fixed; inset:0; background:var(--overlay); z-index:100; display:flex; align-items:center; justify-content:center;
  padding:20px; padding-top:calc(20px + env(safe-area-inset-top,0px)); padding-bottom:calc(20px + env(safe-area-inset-bottom,0px));
  animation:fadeIn .15s ease;
}
.modal-box{
  background:var(--surface); border:1px solid var(--border-soft); border-radius:var(--radius-lg); width:100%; max-width:560px;
  max-height:88vh; display:flex; flex-direction:column; box-shadow:var(--shadow); animation:popIn .18s ease;
}
.modal-box.wide{max-width:820px;}
.modal-head{display:flex; align-items:center; justify-content:space-between; padding:20px 24px; border-bottom:1px solid var(--border-soft);}
.modal-head h3{font-size:18px;}
.modal-body{padding:22px 24px; overflow-y:auto;}
.modal-foot{padding:16px 24px; border-top:1px solid var(--border-soft); display:flex; justify-content:flex-end; gap:10px;}
@keyframes fadeIn{from{opacity:0} to{opacity:1}}
@keyframes popIn{from{opacity:0; transform:translateY(10px) scale(.98)} to{opacity:1; transform:none}}

/* ============================================================
   Toasts
   ============================================================ */
.toast-root{position:fixed; bottom:20px; right:20px; z-index:200; display:flex; flex-direction:column; gap:10px; max-width:calc(100vw - 40px);}
.toast{
  background:var(--surface); border:1px solid var(--border-soft); border-left:4px solid var(--gold); color:var(--text);
  padding:13px 16px; border-radius:10px; box-shadow:var(--shadow); font-size:13px; font-weight:600; min-width:240px;
  animation:slideIn .2s ease;
}
.toast.success{border-left-color:var(--success);}
.toast.danger{border-left-color:var(--danger);}
@keyframes slideIn{from{opacity:0; transform:translateX(20px)} to{opacity:1; transform:none}}

/* ============================================================
   Chat / messagerie
   ============================================================ */
.chat-shell{display:flex; height:calc(100vh - var(--topbar-h) - 44px); border:1px solid var(--border-soft); border-radius:var(--radius-md); overflow:hidden; background:var(--surface);}
.chat-sidebar{width:280px; flex-shrink:0; border-right:1px solid var(--border-soft); overflow-y:auto;}
.chat-conv-item{display:flex; gap:10px; padding:14px 16px; border-bottom:1px solid var(--border-soft); cursor:pointer;}
.chat-conv-item:hover, .chat-conv-item.active{background:var(--surface-hover);}
.chat-main{flex:1; display:flex; flex-direction:column; min-width:0;}
.chat-head{padding:14px 18px; border-bottom:1px solid var(--border-soft); font-weight:700;}
.chat-messages{flex:1; overflow-y:auto; padding:18px; display:flex; flex-direction:column; gap:12px;}
.msg-row{display:flex; gap:9px; max-width:78%;}
.msg-row.mine{align-self:flex-end; flex-direction:row-reverse;}
.msg-bubble{background:var(--surface-2); border:1px solid var(--border-soft); padding:10px 13px; border-radius:14px; font-size:13.5px; line-height:1.45;}
.msg-row.mine .msg-bubble{background:var(--gold-soft); border-color:transparent;}
.msg-meta{font-size:10.5px; color:var(--text-faint); margin-top:4px;}
.chat-input-row{display:flex; align-items:flex-end; gap:10px; padding:14px 16px; border-top:1px solid var(--border-soft); background:var(--surface-2);}
.chat-input-row textarea{
  flex:1; resize:none; font-family:var(--font-sans); font-size:14px; line-height:1.4; color:var(--text);
  background:var(--surface); border:1px solid var(--border); border-radius:16px;
  padding:11px 16px; min-height:44px; max-height:140px; outline:none; transition:.15s ease;
}
.chat-input-row textarea::placeholder{color:var(--text-faint);}
.chat-input-row textarea:focus{border-color:var(--gold); box-shadow:0 0 0 3px var(--gold-soft);}
.chat-input-row .btn{flex-shrink:0; min-height:44px;}
@media (max-width:768px){ .chat-shell{flex-direction:column; height:auto;} .chat-sidebar{width:100%; max-height:180px; border-right:none; border-bottom:1px solid var(--border-soft);} .chat-messages{max-height:50vh;} }

/* ============================================================
   Calendrier
   ============================================================ */
.cal-card{max-width:none;}
.cal-head{display:flex; align-items:center; justify-content:space-between; margin-bottom:20px; gap:10px; flex-wrap:wrap;}
.cal-head h3{font-size:22px;}
.cal-grid{display:grid; grid-template-columns:repeat(7,minmax(0,1fr)); gap:8px;}
.cal-grid.cal-body{grid-auto-rows:1fr;}
.cal-dow{text-align:center; font-size:13px; color:var(--text-faint); font-weight:800; text-transform:uppercase; padding-bottom:8px;}
.cal-cell{
  height:150px; box-sizing:border-box; border:1px solid var(--border-soft); border-radius:12px; padding:9px; background:var(--surface-2);
  display:flex; flex-direction:column; gap:4px; cursor:pointer; transition:.15s; overflow:hidden; min-width:0;
}
.cal-cell:hover{border-color:var(--gold-dark); background:var(--surface-hover);}
.cal-cell.other-month{opacity:.35;}
.cal-cell.today{border-color:var(--gold); box-shadow:0 0 0 1px var(--gold);}
.cal-daynum{font-size:16px; font-weight:800; color:var(--text-dim); flex-shrink:0;}
.cal-cell.today .cal-daynum{color:var(--gold);}
.cal-evt{font-size:12px; padding:4px 9px; border-radius:100px; background:var(--gold-soft); color:var(--gold); font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; flex-shrink:0; max-width:100%;}
.cal-evt.confirme{background:var(--success-soft); color:var(--success);}
.cal-evt.refuse{background:var(--danger-soft); color:var(--danger);}
.cal-evt.termine{background:var(--surface); color:var(--text-faint);}
@media (max-width:1100px){ .cal-cell{height:120px;} }
@media (max-width:768px){ .cal-grid{grid-template-columns:repeat(7,minmax(0,1fr)); gap:5px;} .cal-cell{height:60px; padding:4px; border-radius:8px;} .cal-daynum{font-size:12px;} .cal-evt{display:none;} .cal-cell.has-evt::after{content:""; width:5px; height:5px; border-radius:50%; background:var(--gold); align-self:center;} }

/* ============================================================
   Stats
   ============================================================ */
.chart-card{background:var(--surface); border:1px solid var(--border-soft); border-radius:var(--radius-md); padding:18px;}
.chart-card h4{font-size:14px; margin-bottom:14px;}
.chart-card canvas{max-height:260px;}

/* ============================================================
   Settings / logo uploader
   ============================================================ */
.logo-uploader{display:flex; align-items:center; gap:18px; flex-wrap:wrap;}
.logo-preview{width:90px; height:90px; border-radius:16px; border:1px solid var(--border-soft); object-fit:contain; background:var(--surface-2); padding:8px;}
.theme-switch{display:flex; align-items:center; gap:10px; background:var(--surface-2); border:1px solid var(--border-soft); border-radius:100px; padding:4px;}
.theme-switch button{border:none; background:none; padding:8px 16px; border-radius:100px; font-weight:700; font-size:13px; color:var(--text-dim); cursor:pointer;}
.theme-switch button.active{background:var(--gold); color:#1a1405;}

.priority-hint{font-size:12px; color:var(--text-faint); margin-top:4px;}

.stepper{display:flex; align-items:center; gap:10px; margin-bottom:22px; flex-wrap:wrap;}
.stepper .step{display:flex; align-items:center; gap:8px; font-size:12.5px; font-weight:700; color:var(--text-faint);}
.stepper .step.active{color:var(--gold);}
.stepper .step .num{width:22px; height:22px; border-radius:50%; background:var(--surface-2); border:1px solid var(--border); display:flex; align-items:center; justify-content:center; font-size:11px;}
.stepper .step.active .num{background:var(--gold); color:#1a1405; border-color:var(--gold);}

.pill-select{display:flex; gap:8px; flex-wrap:wrap;}
.pill-select button{padding:9px 15px; border-radius:100px; border:1px solid var(--border); background:var(--surface-2); color:var(--text); font-weight:700; font-size:12.5px; cursor:pointer;}
.pill-select button.active{background:var(--gold-soft); border-color:var(--gold); color:var(--gold);}

/* ---------------- Éditeur de modèle de contrat (PDF) ---------------- */
.tpl-toolbar{display:flex; align-items:center; gap:12px; flex-wrap:wrap; margin-bottom:16px;}
.tpl-dirty-note{font-size:12px; color:var(--gold); font-weight:700;}
.tpl-editor-layout{display:grid; grid-template-columns:220px 1fr 280px; gap:16px; align-items:start;}
@media (max-width:1200px){ .tpl-editor-layout{grid-template-columns:1fr; } }

.tpl-palette{background:var(--surface); border:1px solid var(--border-soft); border-radius:var(--radius-md); padding:14px; max-height:820px; overflow-y:auto;}
.tpl-palette-group{margin-bottom:16px;}
.tpl-palette-group-label{font-size:10.5px; text-transform:uppercase; letter-spacing:.05em; color:var(--text-faint); font-weight:800; margin-bottom:8px;}
.tpl-palette-btn{display:block; width:100%; text-align:left; padding:8px 10px; margin-bottom:6px; border-radius:8px; border:1px solid var(--border); background:var(--surface-2); color:var(--text); font-size:12.5px; font-weight:600; cursor:pointer;}
.tpl-palette-btn:hover{background:var(--surface-hover); border-color:var(--gold-dark);}

.tpl-canvas-wrap{background:var(--surface-2); border:1px solid var(--border-soft); border-radius:var(--radius-md); padding:20px; overflow:auto; max-height:820px; display:flex; justify-content:center;}
.tpl-page{position:relative; background:#fff; box-shadow:0 4px 24px rgba(0,0,0,.35); flex-shrink:0;}
.tpl-block{position:absolute; box-sizing:border-box; padding:3px; cursor:move; overflow:hidden; color:#201c10; font-family:Georgia,'Times New Roman',serif; user-select:none; outline:1px dashed rgba(165,121,31,.55); background-clip:padding-box;}
.tpl-block:hover{outline:1px dashed var(--gold-dark); z-index:2;}
.tpl-block.selected{outline:2px solid var(--gold); z-index:3;}
.tpl-block-content{width:100%; height:100%; overflow:hidden; pointer-events:none; line-height:1.25; white-space:pre-wrap; word-break:break-word;}
.tpl-block-tag{position:absolute; top:-18px; left:0; opacity:0; transition:opacity .1s; background:var(--gold); color:#1a1405; font-family:'Manrope',system-ui,sans-serif; font-size:9.5px; font-weight:700; padding:2px 6px; border-radius:4px; white-space:nowrap; z-index:5; pointer-events:none;}
.tpl-block.selected .tpl-block-tag, .tpl-block:hover .tpl-block-tag{opacity:1;}
.tpl-resize-handle{position:absolute; right:-4px; bottom:-4px; width:12px; height:12px; border-radius:3px; background:var(--gold); cursor:nwse-resize; z-index:4;}

/* ---------------- Widget "Mes notes" ---------------- */
.notes-grid{display:grid; grid-template-columns:repeat(auto-fill, minmax(260px,1fr)); gap:14px; margin-top:4px;}
.note-card{background:var(--surface-2); border:1px solid var(--border-soft); border-radius:var(--radius-md); overflow:hidden; display:flex; flex-direction:column;}
.note-toolbar{display:flex; align-items:center; gap:4px; padding:6px 8px; border-bottom:1px solid var(--border-soft); background:var(--surface); flex-wrap:wrap;}
.note-toolbar select{font-size:11.5px; padding:3px 4px; border-radius:6px; border:1px solid var(--border); background:var(--surface-2); color:var(--text); max-width:78px;}
.note-toolbar button{width:26px; height:26px; border-radius:6px; border:1px solid var(--border); background:var(--surface-2); color:var(--text); cursor:pointer; font-size:12px; flex-shrink:0;}
.note-toolbar button:hover{background:var(--surface-hover);}
.note-toolbar input[type=color]{width:26px; height:26px; padding:2px; border-radius:6px; border:1px solid var(--border); background:none; cursor:pointer; flex-shrink:0;}
.note-toolbar .note-del{margin-left:auto; border-color:transparent; color:var(--danger);}
.note-body{flex:1; min-height:120px; max-height:260px; padding:10px 12px; font-size:13px; line-height:1.5; outline:none; overflow-y:auto; color:var(--text);}
.note-body h1{font-size:18px; margin:6px 0; color:var(--text);}
.note-body h2{font-size:15.5px; margin:5px 0; color:var(--text);}
.note-body h3{font-size:13.5px; margin:4px 0; color:var(--text);}
.note-body:empty:before{content:"Écrivez votre note…"; color:var(--text-faint);}

.tpl-props{background:var(--surface); border:1px solid var(--border-soft); border-radius:var(--radius-md); padding:16px; max-height:820px; overflow-y:auto;}
.tpl-props-title{font-weight:800; margin-bottom:12px; font-size:13.5px; color:var(--gold);}

.tpl-pagebar{display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; margin-bottom:12px;}
.tpl-page-tabs{display:flex; gap:6px; flex-wrap:wrap;}
.tpl-page-tab{display:flex; align-items:center; gap:6px; padding:7px 12px; border-radius:8px; border:1px solid var(--border); background:var(--surface-2); color:var(--text); font-size:12px; font-weight:700; cursor:pointer;}
.tpl-page-tab.active{background:var(--gold-soft); border-color:var(--gold); color:var(--gold);}
.tpl-page-tab.tpl-page-add{background:transparent; border-style:dashed;}
.tpl-page-del{opacity:.6; font-size:10px;}
.tpl-page-del:hover{opacity:1; color:var(--danger);}
.tpl-zoom-controls{display:flex; align-items:center; gap:6px;}
.tpl-zoom-controls .icon-btn{width:30px; height:30px;}
.tpl-zoom-reset{min-width:52px; padding:6px 8px; border-radius:8px; border:1px solid var(--border); background:var(--surface-2); color:var(--text-dim); font-size:11.5px; font-weight:700; cursor:pointer;}
