/* CLAUMEL Performance Hub™ — identité CLAUMEL : ivoire, noir, or, anthracite */
:root {
  --ivory: #F6F4F0; --paper: #FFFFFF; --ink: #141414; --anthracite: #3A3A3A; --grey: #77726A; --line: #E4DFD5;
  --gold: #B8902F; --gold-soft: #F1E7CC; --ok: #2F6B3F; --warn: #9A6B12; --bad: #9E2B21;
  --serif: 'Playfair Display', Georgia, serif; --sans: 'Montserrat', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ivory); color: var(--ink); font: 15px/1.5 var(--sans); }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-wrap: break-word; }
img, svg { max-width: 100%; }
a { color: var(--ink); }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; margin: 0 0 .4em; }
h1 { font-size: 30px; } h3 { font-size: 19px; } h4 { font-size: 16px; }
code { background: var(--gold-soft); padding: 1px 5px; border-radius: 3px; font-size: 12px; word-break: break-all; }
.muted { color: var(--grey); } .small { font-size: 13px; } .mono { font-variant-numeric: tabular-nums; } .nowrap { white-space: nowrap; } .right { text-align: right; }
.neg { color: var(--bad); } .pos { color: var(--ok); }
.big { font-family: var(--serif); font-size: 44px; margin: 0; line-height: 1; }

/* Barre supérieure */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 28px; background: var(--paper); border-bottom: 1px solid var(--gold); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-name { font-family: var(--serif); font-size: 18px; color: var(--gold); }
.topbar nav { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.topbar nav a { text-decoration: none; }
.topbar .who { overflow-wrap: anywhere; }
.menu-toggle { display: none; font: inherit; font-size: 14px; font-weight: 600; align-items: center; gap: 6px; padding: 8px 12px; min-height: 40px; border: 1px solid var(--gold); border-radius: 4px; background: var(--paper); color: var(--ink); cursor: pointer; }
.menu-icon { font-size: 16px; line-height: 1; color: var(--gold); }
.logo { height: 92px; width: auto; display: block; margin: 0 auto 6px; }
.logo.small { height: 44px; margin: 0; }
.demo-banner { background: var(--gold-soft); color: var(--anthracite); text-align: center; font-size: 13px; padding: 6px 16px; }
main { min-height: calc(100vh - 140px); }
.foot { text-align: center; color: var(--grey); font-size: 12px; padding: 24px 16px; }

/* Pages */
.page { max-width: 1180px; margin: 0 auto; padding: 28px 24px 40px; }
.page.narrow { max-width: 720px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.center { display: grid; place-items: center; gap: 12px; padding: 80px 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 16px; }
.grid > *, .two-col > *, .form-grid > *, .stats > * { min-width: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } .page { padding: 20px 16px; } .topbar { padding: 10px 16px; } h1 { font-size: 24px; } }

/* Cartes */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 20px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h3 { margin: 0; }
.link-card { text-decoration: none; display: block; transition: border-color .15s; }
.link-card:hover { border-color: var(--gold); }

/* Indicateurs */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-top: 3px solid var(--gold); border-radius: 6px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--grey); }
.stat-value { font-family: var(--serif); font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--grey); } .stat-sub.up { color: var(--ok); } .stat-sub.down { color: var(--bad); }

/* Onglets */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; scrollbar-width: thin; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--anthracite); font-size: 14px; white-space: nowrap; border-bottom: 3px solid transparent; }
.tabs a.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--gold); }

/* Formulaires */
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--anthracite); min-width: 0; }
.field > input, .field > select, .field > textarea { width: 100%; }
.field small { color: var(--grey); }
input, select, textarea { font: inherit; font-size: 14px; padding: 9px 10px; border: 1px solid #CFC8BA; border-radius: 4px; background: #fff; color: var(--ink); min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 0; border-color: var(--gold); }
textarea { resize: vertical; }
/* Champs date / mois : sur iPhone, Safari leur impose une largeur propre et centre la valeur → on les aligne sur les autres champs */
input[type=date], input[type=month], input[type=time] { -webkit-appearance: none; appearance: none; display: block; max-width: 100%; min-width: 0; min-height: 40px; text-align: left; }
input[type=date]::-webkit-date-and-time-value, input[type=month]::-webkit-date-and-time-value { text-align: left; margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr)); gap: 12px 16px; align-items: end; margin-bottom: 8px; }
.form-grid .field:has(textarea) { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.inline-form input { flex: 1 1 180px; }
.btn { font: inherit; font-size: 14px; font-weight: 600; padding: 9px 18px; border-radius: 4px; border: 1px solid var(--ink); background: var(--ink); color: #fff; cursor: pointer; text-decoration: none; display: inline-block; text-align: center; }
.btn:hover { background: var(--anthracite); }
.btn.gold { background: var(--gold); border-color: var(--gold); } .btn.gold:hover { background: #9E7A24; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { background: none; border: none; color: var(--anthracite); text-decoration: underline; cursor: pointer; font: inherit; font-size: 13px; padding: 2px 0; }
.link.danger { color: var(--bad); }

/* Tableaux & listes */
.table-wrap { overflow-x: auto; margin-top: 8px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--grey); border-bottom: 1px solid var(--gold); padding: 8px; }
.table td { border-bottom: 1px solid var(--line); padding: 8px; vertical-align: top; }
.empty { color: var(--grey); text-align: center; padding: 20px; }
.list { list-style: none; padding: 0; margin: 0 0 10px; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list.compact li { justify-content: flex-start; padding: 6px 0; }
.row-actions { display: flex; gap: 10px; align-items: center; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .03em; padding: 2px 8px; border-radius: 10px; background: #EEEAE2; color: var(--anthracite); }
.badge.gold { background: var(--gold-soft); color: #7A5D17; } .badge.ok { background: #E1EEE3; color: var(--ok); }
.badge.warn { background: #F6ECD6; color: var(--warn); } .badge.bad { background: #F5DEDB; color: var(--bad); }
.notice { padding: 10px 14px; border-radius: 4px; margin: 10px 0; font-size: 14px; background: var(--gold-soft); }
.notice.error { background: #F5DEDB; color: var(--bad); } .notice.ok { background: #E1EEE3; color: var(--ok); }

/* Graphiques */
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); } .chart .axis { font-size: 11px; fill: var(--grey); font-family: var(--sans); }
.chart .cursor { stroke: var(--gold); stroke-dasharray: 3 3; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.gapbars { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 10px; }
.gaprow { display: grid; grid-template-columns: 190px 1fr 150px; gap: 10px; align-items: center; font-size: 13px; }
.gaptrack { position: relative; height: 16px; background: #F3F0EA; border-radius: 2px; }
.gapzero { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--anthracite); }
.gapbar { position: absolute; top: 0; bottom: 0; } .gapbar.neg { background: var(--bad); } .gapbar.pos { background: var(--gold); }
.gapvalue { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .gaprow { grid-template-columns: 1fr; gap: 2px; } .gapvalue { text-align: left; } }

/* Decision Engine */
.reco { border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: 4px; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.reco h4 { margin: 0; } .reco p { margin: 0; font-size: 14px; }
.reco-head { display: flex; gap: 6px; }
.note { background: var(--ivory); padding: 6px 10px; font-style: italic; }

/* Ask CLAUMEL */
.thread { display: flex; flex-direction: column; gap: 10px; max-height: 460px; overflow-y: auto; padding: 4px; margin-bottom: 12px; }
.msg { max-width: 78%; padding: 10px 14px; border-radius: 8px; background: var(--ivory); align-self: flex-start; }
.msg.consultant { background: var(--gold-soft); }
.msg.mine { align-self: flex-end; }
.msg-meta { font-size: 11px; color: var(--grey); margin-bottom: 3px; }
.msg-body { white-space: pre-wrap; }
.composer { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { flex: 1; }
@media (max-width: 640px) { .composer { flex-direction: column; align-items: stretch; } .msg { max-width: 92%; } }

/* Actions 30/60/90 */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.kanban .col { background: var(--ivory); border-radius: 4px; padding: 10px; min-height: 80px; }
.kanban h4 { font-family: var(--sans); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--gold); }
.task { background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.task.termine { opacity: .7; } .task.termine strong { text-decoration: line-through; }
@media (max-width: 760px) { .kanban { grid-template-columns: 1fr; } }
.review { border-bottom: 1px solid var(--line); padding: 8px 0 12px; margin-bottom: 8px; } .review p { margin: 4px 0; }

/* Connexion */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 400px; background: var(--paper); border: 1px solid var(--line); border-top: 3px solid var(--gold); border-radius: 6px; padding: 30px 28px; display: flex; flex-direction: column; gap: 14px; text-align: center; }
.login-card .field { text-align: left; }
.login-card h1 { font-size: 26px; margin: 0; color: var(--gold); }
.demo-accounts { text-align: left; font-size: 13px; background: var(--ivory); padding: 10px 12px; border-radius: 4px; display: flex; flex-direction: column; gap: 2px; }
.demo-accounts .link { text-align: left; }
.logo-text { font-family: var(--serif); letter-spacing: .18em; color: var(--ink); font-size: 18px; display: block; text-align: center; margin-bottom: 6px; }
.logo-text.small { font-size: 13px; letter-spacing: .14em; margin: 0; }

/* Établissements : cartes sur téléphone, tableau sur grand écran */
.est-cards { display: none; }
.est-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.est-card-name { font-family: var(--serif); font-size: 18px; font-weight: 600; text-decoration: none; }
.est-card-head p { margin: 2px 0 0; }
.est-card-kpis { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0; background: var(--ivory); border-radius: 4px; padding: 4px 10px; }
.est-card-kpis div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.est-card-kpis div:last-child { border-bottom: 0; }
.est-card-kpis dt { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--grey); }
.est-card-kpis dd { margin: 0; font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; text-align: right; }
.est-card-actions { display: flex; gap: 8px; }
.est-card-actions .btn { flex: 1; }

/* Téléphone (iPhone : 375 à 430 px) */
@media (max-width: 760px) {
  .topbar { padding: 8px 16px; gap: 8px 10px; flex-wrap: wrap; }
  .menu-toggle { flex: 0 0 auto; padding: 8px 10px; }
  .logo.small { height: 48px; }
  .brand { gap: 10px; min-width: 0; flex: 1 1 0; }
  .brand .logo.small { flex: 0 0 auto; }
  .brand-name { font-size: 14px; line-height: 1.2; min-width: 0; overflow-wrap: normal; }
  .menu-toggle { display: inline-flex; }
  .topbar nav { display: none; width: 100%; flex-direction: column; align-items: stretch; gap: 0; border-top: 1px solid var(--line); padding-top: 4px; }
  .topbar.open nav { display: flex; }
  .topbar nav a, .topbar nav .link { padding: 12px 2px; font-size: 15px; border-bottom: 1px solid var(--line); text-align: left; }
  .topbar nav .link { border-bottom: 0; color: var(--bad); }
  .topbar .who { color: var(--grey); font-size: 14px; }

  .page { padding: 18px 16px 32px; }
  h1 { font-size: 24px; overflow-wrap: anywhere; }
  .card { padding: 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 10px 12px; }
  .stat-value { font-size: 18px; }

  /* Onglets des modules : grille compacte de 2 colonnes, tout visible */
  .tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; border-bottom: 0; overflow: visible; }
  .tabs a { white-space: normal; text-align: center; font-size: 13px; line-height: 1.25; padding: 9px 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); display: flex; align-items: center; justify-content: center; }
  .tabs a.active { border-color: var(--gold); background: var(--gold-soft); }

  /* Champs : 16 px pour éviter le zoom automatique de Safari iPhone */
  input, select, textarea { font-size: 16px; width: 100%; }
  input[type=date], input[type=month] { min-height: 44px; }
  .inline-form > *, .form-actions .btn { flex: 1 1 100%; }
  .card-head .card-actions { width: 100%; }
  .card-head .card-actions select { width: 100%; }

  .est-cards { display: block; }
  .est-table { display: none; }

  /* Tableaux détaillés : une carte par ligne, étiquette à gauche, valeur à droite */
  .table.stack thead { display: none; }
  .table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
  .table.stack tr { border: 1px solid var(--line); border-radius: 4px; padding: 6px 10px; margin-bottom: 8px; background: var(--paper); }
  .table.stack td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 0; text-align: right; }
  .table.stack td::before { content: attr(data-label); color: var(--grey); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; text-align: left; flex: 0 0 auto; }
  .table.stack td.stack-title { font-weight: 600; border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 2px; text-align: left; }
  .table.stack td.stack-title::before { content: none; }
  .table.stack td.empty { display: block; text-align: center; }
  .table.stack td.empty::before { content: none; }
  .table.stack td[data-label=""]::before { content: none; }
  .table-wrap { overflow-x: visible; }
}
