/* CRM Sobria — palette « Nuit & Cuivre » (reprise du site) */
:root {
  --nuit: #141c2b;
  --nuit-2: #1d2839;
  --nuit-3: #263349;
  --cuivre: #c47a4a;
  --cuivre-clair: #d99a6c;
  --creme: #f6f1e8;
  --ardoise: #5b6b82;
  --ok: #4caf7d;
  --warn: #e0a03c;
  --danger: #d95f4a;
  --radius: 10px;
  --font-body: Inter, -apple-system, "Segoe UI", sans-serif;
  --font-head: "PT Serif", Georgia, serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--nuit);
  color: var(--creme);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-head); font-weight: 700; }
a { color: var(--cuivre-clair); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 15px;
  background: var(--nuit); color: var(--creme);
  border: 1px solid var(--nuit-3); border-radius: 6px;
  padding: 9px 11px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--cuivre); border-color: transparent; }
label { display: block; font-size: 12.5px; color: var(--ardoise); margin: 10px 0 4px; text-transform: uppercase; letter-spacing: .04em; }
.loading { padding: 40px; text-align: center; color: var(--ardoise); }
.lookup-row { display: flex; gap: 6px; align-items: stretch; }
.lookup-row input { flex: 1; }
.lookup-btn { white-space: nowrap; }

/* ---- boutons */
.btn {
  display: inline-block; border: none; border-radius: 6px;
  padding: 9px 16px; font-size: 14px; font-weight: 600;
  background: var(--nuit-3); color: var(--creme);
}
.btn:hover { filter: brightness(1.15); }
.btn-primary { background: var(--cuivre); color: #fff; }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }

/* ---- login */
.login-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--nuit-2);
  border: 1px solid var(--nuit-3); border-radius: var(--radius); padding: 34px;
}
.login-card h1 { font-size: 26px; margin-bottom: 4px; }
.login-card .sub { color: var(--ardoise); font-size: 13.5px; margin-bottom: 18px; }
.login-card .btn { width: 100%; margin-top: 18px; padding: 12px; }
.error-msg { color: var(--danger); font-size: 13.5px; margin-top: 10px; }

/* ---- structure */
.shell { display: flex; min-height: 100dvh; }
.sidebar {
  width: 218px; flex-shrink: 0; background: var(--nuit-2);
  border-right: 1px solid var(--nuit-3); padding: 22px 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh;
}
.brand { font-family: var(--font-head); font-size: 21px; padding: 0 22px 18px; }
.brand em { color: var(--cuivre); font-style: normal; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 22px; color: var(--creme); font-size: 14.5px; opacity: .75;
  border-left: 3px solid transparent;
}
.nav-link:hover { opacity: 1; }
.nav-link.active { opacity: 1; border-left-color: var(--cuivre); background: rgba(196,122,74,.08); }
.nav-spacer { flex: 1; }
.nav-user { padding: 12px 22px; font-size: 13px; color: var(--ardoise); border-top: 1px solid var(--nuit-3); }
.main { flex: 1; padding: 28px 34px 80px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; }

/* ---- mobile */
.tabbar { display: none; }
@media (max-width: 760px) {
  .sidebar { display: none; }
  .main { padding: 18px 14px 90px; }
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: var(--nuit-2); border-top: 1px solid var(--nuit-3);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    flex: 1; text-align: center; padding: 9px 2px 7px;
    font-size: 10.5px; color: var(--creme); opacity: .65;
  }
  .tabbar a .ico { display: block; font-size: 19px; margin-bottom: 1px; }
  .tabbar a.active { opacity: 1; color: var(--cuivre-clair); }
}

/* ---- cartes / stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat-card { background: var(--nuit-2); border: 1px solid var(--nuit-3); border-radius: var(--radius); padding: 16px 18px; }
.stat-card .num { font-size: 30px; font-weight: 700; font-family: var(--font-head); }
.stat-card .lbl { font-size: 12.5px; color: var(--ardoise); text-transform: uppercase; letter-spacing: .05em; }
.stat-card.accent .num { color: var(--cuivre-clair); }
.stat-card.danger .num { color: var(--danger); }
.card { background: var(--nuit-2); border: 1px solid var(--nuit-3); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.card h2 { font-size: 18px; margin-bottom: 14px; }

/* ---- tableaux / listes */
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--nuit-3);
  color: var(--creme); cursor: pointer;
}
.list-row:hover { background: rgba(255,255,255,.03); }
.list-row:last-child { border-bottom: none; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 600; }
.list-row .meta { font-size: 12.5px; color: var(--ardoise); }
.badge {
  display: inline-block; font-size: 11px; font-weight: 600; border-radius: 99px;
  padding: 2px 9px; text-transform: uppercase; letter-spacing: .04em;
}
.badge-prospect { background: rgba(91,107,130,.25); color: #a8b6c9; }
.badge-client { background: rgba(76,175,125,.18); color: var(--ok); }
.badge-urgente, .badge-depassee { background: rgba(217,95,74,.18); color: var(--danger); }
.badge-active { background: rgba(224,160,60,.16); color: var(--warn); }
.badge-veille { background: rgba(91,107,130,.2); color: #a8b6c9; }
.badge-brouillon { background: rgba(91,107,130,.25); color: #a8b6c9; }
.badge-envoye { background: rgba(224,160,60,.16); color: var(--warn); }
.badge-signe { background: rgba(76,175,125,.18); color: var(--ok); }

.list-table { width: 100%; border-collapse: collapse; background: var(--nuit-2); border: 1px solid var(--nuit-3); border-radius: var(--radius); overflow: hidden; }
.list-table th, .list-table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--nuit-3); font-size: 14px; }
.list-table th { color: var(--ardoise); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.list-table tr:last-child td { border-bottom: none; }

.subnav { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--nuit-3); flex-wrap: wrap; }
.subnav a { padding: 9px 4px; margin-right: 18px; font-size: 14px; color: var(--ardoise); border-bottom: 2px solid transparent; }
.subnav a.active { color: var(--creme); border-bottom-color: var(--cuivre); }

/* ---- formulaire devis / facture */
fieldset.fs { border: 1px solid var(--nuit-3); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; }
fieldset.fs legend { padding: 0 6px; font-size: 12.5px; color: var(--cuivre-clair); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
table.lignes { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.lignes th { text-align: left; padding: 6px 5px; color: var(--ardoise); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
table.lignes td { padding: 4px 5px; vertical-align: top; }
table.lignes input, table.lignes select, table.lignes textarea { font-size: 13.5px; padding: 6px 8px; }
table.lignes textarea { resize: vertical; min-height: 48px; font-family: inherit; }
.picker-row { padding: 9px 12px; border: 1px solid var(--nuit-3); border-top: none; cursor: pointer; font-size: 14px; }
.picker-row:first-child { border-top: 1px solid var(--nuit-3); border-radius: 6px 6px 0 0; }
.picker-row:last-child { border-radius: 0 0 6px 6px; }
.picker-row:hover { background: rgba(255,255,255,.04); }
.picker-row .meta { color: var(--ardoise); font-size: 12.5px; margin-left: 6px; }

/* ---- timeline « suivi de colis » d'un dossier */
.timeline-list { border-left: 2px solid var(--nuit-3); margin: 8px 0 14px 8px; padding-left: 16px; }
.timeline-step { padding: 7px 0; }
.timeline-step .step-label { font-size: 14.5px; }
.timeline-step.done .step-label { color: var(--ok); }
.timeline-step .step-meta, .step-meta { font-size: 12px; color: var(--ardoise); margin-left: 28px; }

/* ---- marque blanche */
.brand-logo { max-height: 30px; max-width: 150px; object-fit: contain; }
.org-logo-thumb { max-height: 40px; max-width: 120px; object-fit: contain; border-radius: 4px; }
.color-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-left: 6px; vertical-align: middle; border: 1px solid rgba(255,255,255,.25); }

/* ---- assistant IA de dossier */
.ai-summary { max-height: 420px; overflow-y: auto; font-size: 14px; }
.ai-summary p { margin: 0 0 10px; }
.ai-summary ul { margin: 0 0 10px 20px; }
.ai-summary strong { color: var(--cuivre-clair); }

/* ---- statistiques */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 14px; }
.stat-value { font-family: var(--font-head); font-size: 24px; color: var(--cuivre-clair); }
.stat-label { font-size: 12px; color: var(--ardoise); text-transform: uppercase; letter-spacing: .03em; margin-top: 2px; }

/* ---- cloche de notifications */
.brand { display: flex; align-items: center; justify-content: space-between; }
.bell { position: relative; background: none; border: none; font-size: 18px; padding: 4px 6px; }
.bell-dot { position: absolute; top: 2px; right: 2px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.notif-list { max-height: 360px; overflow-y: auto; margin: 10px 0; }
.notif-row { display: block; padding: 10px 12px; border-radius: 6px; margin-bottom: 4px; color: var(--creme); }
.notif-row:hover { background: rgba(255,255,255,.04); }
.notif-row.unread { background: rgba(196,122,74,.1); border-left: 3px solid var(--cuivre); }
.notif-row .content { font-size: 14px; }
.notif-row .meta { font-size: 11.5px; color: var(--ardoise); margin-top: 2px; }

/* ---- fil de discussion */
.chat-tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.chat-tabs button { flex: 1; }
.chat-tabs button.active { background: var(--cuivre); color: #fff; }
.chat-log { max-height: 320px; overflow-y: auto; border: 1px solid var(--nuit-3); border-radius: var(--radius); padding: 10px; margin-bottom: 10px; }
.chat-msg { padding: 8px 10px; border-radius: 8px; margin-bottom: 8px; background: var(--nuit-3); }
.chat-msg.mine { background: rgba(196,122,74,.14); }
.chat-msg .who { font-size: 11.5px; color: var(--ardoise); margin-bottom: 3px; }
.chat-msg .body { font-size: 14px; white-space: pre-wrap; }
.chat-form { display: flex; gap: 8px; }
.chat-form textarea { flex: 1; min-height: 44px; resize: vertical; }
@media (max-width: 760px) {
  table.lignes thead { display: none; }
  table.lignes, table.lignes tbody, table.lignes tr, table.lignes td { display: block; width: 100%; }
  table.lignes tr { border-bottom: 2px solid var(--nuit-3); margin-bottom: 12px; padding-bottom: 8px; }
  table.lignes td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--ardoise); text-transform: uppercase; margin-bottom: 2px; }
}

/* ---- pipeline kanban */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; }
.kcol { flex: 0 0 240px; background: var(--nuit-2); border: 1px solid var(--nuit-3); border-radius: var(--radius); padding: 10px; }
.kcol h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--ardoise); font-family: var(--font-body); padding: 4px 6px 10px; display:flex; justify-content: space-between; }
.kcard {
  background: var(--nuit); border: 1px solid var(--nuit-3); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 8px; cursor: grab; font-size: 13.5px;
}
.kcard .company { font-weight: 600; }
.kcard .meta { color: var(--ardoise); font-size: 12px; margin-top: 2px; }
.kcard.dragging { opacity: .4; }
.kcol.dragover { outline: 2px dashed var(--cuivre); }

/* ---- fiche entreprise */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.timeline-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--nuit-3); font-size: 13.5px; }
.timeline-item:last-child { border: none; }
.timeline-item .kind { flex-shrink: 0; font-size: 17px; }
.timeline-item .who { color: var(--ardoise); font-size: 12px; }
.timeline-item.done .content { text-decoration: line-through; opacity: .55; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-actions { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; }

/* ---- modale */
.modal-back {
  position: fixed; inset: 0; background: rgba(10,14,22,.72); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 14px; overflow-y: auto;
}
.modal {
  background: var(--nuit-2); border: 1px solid var(--nuit-3); border-radius: var(--radius);
  width: 100%; max-width: 560px; padding: 24px;
}
.modal h2 { font-size: 19px; margin-bottom: 6px; }
.searchbar { max-width: 320px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.empty { color: var(--ardoise); padding: 24px; text-align: center; font-size: 14px; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--cuivre); color: #fff; padding: 10px 22px; border-radius: 99px;
  font-size: 14px; font-weight: 600; z-index: 200; box-shadow: 0 6px 24px rgba(0,0,0,.4);
}
