/* Ostrea CRM — palette brand : craie #f0efe4, nude #fdfcf9, craie dark #dcdccf,
   vert minéral #9eb9b5, bleu abysse #2e2e36, blue low #8f8e8d */
:root {
  --craie: #f0efe4;
  --nude: #fdfcf9;
  --craie-dark: #dcdccf;
  --vert: #9eb9b5;
  --vert-dark: #7fa19c;
  --abysse: #2e2e36;
  --blue-low: #8f8e8d;
  --ok: #3c6e64;
  --warn: #b5651d;
  --danger: #a94438;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(46,46,54,.08);
}
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Helvetica Neue", Arial, sans-serif;
  background: var(--craie);
  color: var(--abysse);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* ---- Header & nav ---- */
#topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: var(--abysse); color: var(--nude);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.logo { font-weight: 700; letter-spacing: .35em; font-size: 17px; }
.baseline { font-size: 12px; color: var(--vert); letter-spacing: .08em; }
.user { display: flex; align-items: center; gap: 8px; font-size: 13px; }
#tabs {
  display: flex; gap: 2px; background: var(--abysse); padding: 0 8px 0;
  position: sticky; top: 49px; z-index: 19; overflow-x: auto;
}
#tabs a {
  color: var(--craie-dark); text-decoration: none; padding: 10px 14px;
  font-size: 13.5px; white-space: nowrap; border-radius: 8px 8px 0 0;
}
#tabs a.active { background: var(--craie); color: var(--abysse); font-weight: 600; }
#tabs a .badge {
  background: var(--warn); color: #fff; border-radius: 9px;
  font-size: 10.5px; padding: 1px 6px; margin-left: 4px; vertical-align: 1px;
}

main { padding: 14px; max-width: 1080px; margin: 0 auto; }

/* ---- Bandeau stats permanent (dans le header noir, centré) ---- */
#statbar {
  flex: 1; display: flex; align-items: center; justify-content: center;
  gap: 16px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--craie-dark); padding: 0 12px;
}
#statbar .sb-item b { font-size: 14px; color: var(--nude); }
#statbar .sb-obj { display: flex; align-items: center; gap: 8px; color: var(--vert); }
#statbar .sb-obj b { color: var(--nude); font-size: 14px; }
#statbar .sb-bar { width: 120px; height: 7px; background: rgba(255,255,255,.14); border-radius: 4px; overflow: hidden; }
#statbar .sb-bar div { height: 100%; background: var(--vert); }
#statbar .sb-alert { color: #f2a08c; font-weight: 700; cursor: pointer; }
@media (max-width: 900px) {
  #statbar { order: 3; flex-basis: 100%; justify-content: center; padding: 6px 0 2px; gap: 10px; }
  #topbar { flex-wrap: wrap; }
}

/* ---- Login ---- */
.login-wrap {
  min-height: 80vh; display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: var(--nude); border-radius: 14px; box-shadow: var(--shadow);
  padding: 36px 30px; width: 100%; max-width: 380px; text-align: center;
}
.login-card .logo-big {
  font-weight: 700; letter-spacing: .4em; font-size: 26px; margin-bottom: 4px;
}
.login-card .sub { color: var(--blue-low); font-size: 13px; margin-bottom: 26px; }
.login-card input {
  width: 100%; padding: 12px; margin-bottom: 12px; border: 1px solid var(--craie-dark);
  border-radius: 8px; font-size: 16px; text-align: center; background: #fff;
}
.login-card .code-input { letter-spacing: .5em; font-size: 22px; }
.login-hint { font-size: 12.5px; color: var(--blue-low); margin-top: 10px; }
.dev-code { margin-top: 12px; padding: 8px; background: var(--craie); border-radius: 8px; font-size: 13px; }

/* ---- Boutons ---- */
button {
  font-family: inherit; font-size: 14px; border: none; border-radius: 8px;
  padding: 10px 16px; cursor: pointer; background: var(--vert); color: var(--abysse);
  font-weight: 600;
}
button:hover { background: var(--vert-dark); color: #fff; }
button.ghost { background: transparent; color: inherit; border: 1px solid var(--craie-dark); font-weight: 400; }
button.ghost:hover { background: var(--craie); color: var(--abysse); }
button.dark { background: var(--abysse); color: var(--nude); }
button.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
button.small { padding: 6px 10px; font-size: 12.5px; }
button:disabled { opacity: .5; cursor: default; }

/* ---- Cartes & listes ---- */
.card {
  background: var(--nude); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 10px;
}
.p-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; cursor: pointer; }
.p-head .sel-box { width: 19px; height: 19px; margin-top: 2px; flex-shrink: 0; accent-color: var(--vert-dark); cursor: pointer; }
.p-head > div:nth-of-type(1) { flex: 1; }
.p-title { font-weight: 600; }
.p-sub { font-size: 12.5px; color: var(--blue-low); margin-top: 2px; }
.p-badges { display: flex; gap: 5px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.badge-f { font-size: 11px; padding: 2px 7px; border-radius: 9px; font-weight: 700; }
.f1 { background: #c9dcd7; color: #2f5a4e; }
.f2 { background: #d6e4e1; color: #3c6e64; }
.f3 { background: #f6ecc9; color: #8a6d1f; }
.f4 { background: #fce4c8; color: #b5651d; }
.badge-s { font-size: 11px; padding: 2px 7px; border-radius: 9px; background: var(--craie); color: var(--abysse); }
.badge-s.rdv_pris, .badge-s.rdv_fait { background: var(--vert); }
.badge-s.signe { background: var(--abysse); color: var(--nude); }
.badge-s.pas_interesse { background: var(--danger); color: #fff; font-weight: 700; }
.badge-s.a_rappeler { background: #f6ecc9; color: #8a6d1f; }

.p-details { margin-top: 12px; border-top: 1px solid var(--craie); padding-top: 12px; font-size: 13.5px; }
.p-contact { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.p-contact a {
  background: var(--craie); color: var(--abysse); text-decoration: none;
  padding: 7px 12px; border-radius: 8px; font-size: 13px;
}
.p-note { color: #55555e; margin-bottom: 10px; line-height: 1.45; }
.p-vigilance { color: var(--warn); font-size: 12.5px; margin-bottom: 10px; }

.call-actions { display: flex; flex-wrap: wrap; gap: 7px; margin: 10px 0; }
.call-actions button { flex: 1 1 40%; min-width: 120px; }

.history { margin-top: 10px; font-size: 12.5px; color: var(--blue-low); }
.history li { margin-bottom: 4px; list-style: none; }
.history b { color: var(--abysse); font-weight: 600; }

/* ---- Filtres ---- */
.filters { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; align-items: center; }
.filters input[type=search], .filters select {
  padding: 9px 12px; border: 1px solid var(--craie-dark); border-radius: 8px;
  font-size: 14px; background: var(--nude);
}
.filters input[type=search] { flex: 1; min-width: 150px; }
.chip {
  background: var(--nude); border: 1px solid var(--craie-dark); border-radius: 16px;
  padding: 6px 13px; font-size: 12.5px; cursor: pointer;
}
.chip.on { background: var(--abysse); color: var(--nude); border-color: var(--abysse); }

/* ---- Kanban ---- */
main.wide { max-width: 1500px; }
.kanban { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 14px; align-items: flex-start; }
.kcol {
  background: rgba(255,255,255,.5); border-radius: var(--radius);
  flex: 1 1 0; min-width: 175px; padding: 10px;
}
.kcol h4 .kadd {
  cursor: pointer; color: var(--blue-low); font-weight: 400; padding: 0 4px;
}
.kcol h4 .kadd:hover { color: var(--abysse); }
.kcard.alerte { border: 2px solid var(--danger); }
.kalert {
  margin-top: 6px; font-size: 11.5px; color: var(--danger); font-weight: 700;
}
.kcol h4 { font-size: 12.5px; margin-bottom: 9px; display: flex; justify-content: space-between; }
.kcol h4 .cnt { color: var(--blue-low); font-weight: 400; }
.kcard {
  background: var(--nude); border-radius: 8px; box-shadow: var(--shadow);
  padding: 10px; margin-bottom: 8px; cursor: grab; font-size: 13px;
}
.kcard .kname { font-weight: 600; margin-bottom: 3px; }
.kcard .kmeta { color: var(--blue-low); font-size: 11.5px; }
.kcard .kcomment { margin-top: 6px; font-size: 12px; color: #55555e; font-style: italic; }
.kcol.dragover { outline: 2px dashed var(--vert); }

/* ---- Pilotage ---- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat {
  background: var(--nude); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; text-align: center;
}
.stat .n { font-size: 26px; font-weight: 700; }
.stat .l { font-size: 11.5px; color: var(--blue-low); letter-spacing: .04em; text-transform: uppercase; margin-top: 3px; }
.stat.accent { background: var(--vert); }
.objective { background: var(--nude); border-radius: var(--radius); padding: 14px; margin-bottom: 16px; box-shadow: var(--shadow); }
.obj-bar { height: 10px; background: var(--craie); border-radius: 5px; overflow: hidden; margin-top: 8px; }
.obj-bar div { height: 100%; background: var(--vert); }
table.ranking { width: 100%; border-collapse: collapse; background: var(--nude); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); font-size: 13.5px; }
table.ranking th { background: var(--abysse); color: var(--nude); text-align: left; padding: 9px 10px; font-size: 12px; }
table.ranking td { padding: 9px 10px; border-bottom: 1px solid var(--craie); }
h3.section { margin: 22px 0 10px; font-size: 15px; }

/* ---- Modal ---- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(46,46,54,.45); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: var(--nude); border-radius: 14px; padding: 22px; width: 100%;
  max-width: 430px; max-height: 88vh; overflow-y: auto;
}
.modal h3 { margin-bottom: 14px; }
.modal label { display: block; font-size: 12.5px; color: var(--blue-low); margin: 10px 0 4px; }
.modal input, .modal select, .modal textarea {
  width: 100%; padding: 10px; border: 1px solid var(--craie-dark); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff;
}
.modal textarea { min-height: 80px; }
.modal .row { display: flex; gap: 8px; }
.modal .row > * { flex: 1; }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; justify-content: flex-end; }

/* ---- Toast ---- */
#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--abysse); color: var(--nude); padding: 11px 20px; border-radius: 10px;
  font-size: 13.5px; opacity: 0; transition: opacity .25s; z-index: 99; pointer-events: none;
  max-width: 90vw;
}
#toast.show { opacity: 1; }

/* ---- Équipe / Import ---- */
.member-row { display: flex; align-items: center; gap: 10px; }
.member-row .grow { flex: 1; }
.member-row .inactive { opacity: .45; }
.role-pill { font-size: 11px; padding: 2px 8px; border-radius: 9px; background: var(--craie); }
.role-pill.admin { background: var(--abysse); color: var(--nude); }
.drop-zone {
  border: 2px dashed var(--craie-dark); border-radius: var(--radius); padding: 30px;
  text-align: center; color: var(--blue-low); background: var(--nude); cursor: pointer;
}
.empty { text-align: center; color: var(--blue-low); padding: 40px 10px; font-size: 14px; }

@media (max-width: 900px) {
  .kcol { min-width: 78vw; flex: 0 0 78vw; }
}
@media (max-width: 640px) {
  main { padding: 10px; }
  .call-actions button { flex: 1 1 45%; min-width: 100px; padding: 12px 8px; }
}
