:root {
  --orange: #f77f00;
  --green: #009a44;
  --dark: #1f2937;
  --bg: #f4f5f7;
  --border: #e2e5ea;
  --danger: #c0392b;
}
* { box-sizing: border-box; margin: 0; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--dark); font-size: 15px; overflow-x: hidden; }
.hidden { display: none !important; }
.muted { color: #6b7280; font-weight: normal; font-size: 0.9em; }

/* Connexion */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--orange) 0%, #fff 50%, var(--green) 100%); }
.login-card { background: #fff; padding: 2.2rem; border-radius: 12px; width: 360px; max-width: 92vw;
  box-shadow: 0 12px 40px rgba(0,0,0,.18); display: flex; flex-direction: column; gap: .9rem; text-align: center; }
.login-logo { width: 64px; height: 64px; margin: 0 auto; border-radius: 50%; background: var(--green);
  color: #fff; font-weight: 800; font-size: .95rem; letter-spacing: .02em; display: flex; align-items: center; justify-content: center; }
.login-card h1 { font-size: 1.05rem; }
.login-card label { text-align: left; font-size: .85rem; font-weight: 600; display: flex; flex-direction: column; gap: .3rem; }
input, select { padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 7px; font-size: .95rem; width: 100%; background:#fff; }
input:focus, select:focus { outline: 2px solid var(--orange); border-color: transparent; }

/* Barre du haut */
.topbar { background: #fff; border-bottom: 3px solid var(--orange); display: flex; align-items: center;
  gap: 1.2rem; padding: .6rem 1.2rem; flex-wrap: wrap; position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; display: flex; align-items: center; gap: .5rem; }
.brand-badge { background: var(--green); color: #fff; border-radius: 6px; padding: .15rem .5rem; font-size: .85rem; }
nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.nav-btn { background: none; border: none; padding: .55rem .8rem; border-radius: 7px; cursor: pointer; font-size: .92rem; color: #374151; }
.nav-btn:hover { background: #f3f4f6; }
.nav-btn.active { background: var(--orange); color: #fff; font-weight: 600; }
.user-zone { display: flex; align-items: center; gap: .7rem; }

main { max-width: 1250px; margin: 0 auto; padding: 1.4rem 1.2rem 3rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; margin-bottom: .7rem; }
.inline { display: inline-flex; align-items: center; gap: .5rem; font-weight: 600; }
.inline select, .inline input { width: auto; }

.card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 1rem 1.1rem; margin-bottom: 1.1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
@media (max-width: 1250px) { .grid-2 { grid-template-columns: 1fr; } }

/* Tableaux */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .85rem; }
th, td { padding: .4rem .5rem; border-bottom: 1px solid var(--border); text-align: left; }
td.num, th.num { white-space: nowrap; }
th { background: #f8f9fb; font-size: .72rem; text-transform: uppercase; letter-spacing: .02em; color: #4b5563; }
tr:hover td { background: #fafbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-weight: 700; font-size: .8rem; }
.badge.A { background: #d9f2e3; color: #00722f; }
.badge.B { background: #fff0dc; color: #b25b00; }
.badge.C { background: #fde8e8; color: #b03030; }
.badge.D { background: #ececf1; color: #555; }
.badge.G { background: #4b5563; color: #fff; font-size: .68rem; letter-spacing: .04em; }
tr.gele td { opacity: .65; }
.up { color: var(--green); font-weight: 700; }
.down { color: var(--danger); font-weight: 700; }
.alerte-card { border-left: 4px solid var(--orange); }
.svc-classements-titre { margin: 1.4rem 0 .9rem; font-size: 1.1rem; }
tr.dir-row td { background: #f0f4f1; font-weight: 700; border-top: 2px solid var(--border); }
td.svc-cell { padding-left: 1.6rem; }
.actions { white-space: nowrap; }
.head-actions { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.filters { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: .8rem; }
.filters input[type=search] { flex: 1; min-width: 180px; width: auto; }
.filters select { width: auto; }
.check-label { flex-direction: row !important; align-items: center; gap: .5rem !important; }
.check-label input { width: auto; }

dialog { border: none; border-radius: 12px; padding: 0; box-shadow: 0 16px 50px rgba(0,0,0,.25);
  margin: auto; /* le reset « * { margin: 0 } » annule le centrage natif des dialogues — on le rétablit */ }
dialog::backdrop { background: rgba(0,0,0,.4); }
.dialog-card { padding: 1.4rem; width: 340px; max-width: 90vw; display: flex; flex-direction: column; gap: .8rem; }
.dialog-card label { font-size: .85rem; font-weight: 600; display: flex; flex-direction: column; gap: .3rem; }

/* Formulaires */
.btn { border: 1px solid var(--border); background: #fff; padding: .5rem .9rem; border-radius: 7px;
  cursor: pointer; font-size: .9rem; text-decoration: none; color: var(--dark); display: inline-block; }
.btn:hover { background: #f3f4f6; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #007a36; }
.btn.small { padding: .3rem .7rem; font-size: .82rem; }
.btn.danger { color: var(--danger); }
.btn.full { width: 100%; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .8rem; }
.form-grid label { font-size: .82rem; font-weight: 600; display: flex; flex-direction: column; gap: .3rem; }
.form-actions { grid-column: 1 / -1; display: flex; gap: .6rem; }
.error { background: #fde8e8; color: var(--danger); padding: .5rem .8rem; border-radius: 7px; font-size: .85rem; }
.msg { margin-top: .6rem; font-size: .88rem; }
.msg.ok { color: var(--green); }
.msg.err { color: var(--danger); }
.note { margin-top: .3rem; font-size: .82rem; }

.btn-modele { font-size: .9rem; padding: .5rem .9rem; font-weight: 700; box-shadow: 0 2px 8px rgba(0, 154, 68, .3); margin: .9rem 0; }
.btn-modele:hover { transform: translateY(-1px); }

/* Sous-onglets (page Services) */
.subtabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1.1rem;
  background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: .35rem; }
.subtab { background: none; border: none; padding: .5rem .9rem; border-radius: 7px;
  cursor: pointer; font-size: .9rem; color: #374151; font-weight: 600; }
.subtab:hover { background: #f3f4f6; }
.subtab.active { background: var(--green); color: #fff; }

/* Point d'information (explication au survol) */
.info-dot { display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px;
  border-radius: 50%; background: var(--orange); color: #fff; font-size: .72rem; font-weight: 700; cursor: help; }

/* Fiche détaillée d'un agent */
#fiche-dialog { width: min(780px, 96vw); }
.fiche-card { width: 100%; max-height: 88vh; overflow-y: auto; gap: 1rem; }
.fiche-entete { display: flex; align-items: center; gap: .9rem;
  background: linear-gradient(120deg, var(--green), #00722f); color: #fff;
  margin: -1.4rem -1.4rem 0; padding: 1.1rem 1.4rem; border-radius: 12px 12px 0 0; }
.fiche-avatar { width: 52px; height: 52px; border-radius: 50%; flex: none;
  background: rgba(255,255,255,.18); border: 2px solid rgba(255,255,255,.5);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.15rem; }
.fiche-nom { font-weight: 700; font-size: 1.12rem; line-height: 1.25; }
.fiche-sous { font-size: .84rem; opacity: .92; }
.fiche-infos { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .7rem;
  background: #f8f9fb; border: 1px solid var(--border); border-radius: 10px; padding: .8rem .9rem; }
.fiche-infos > div { min-width: 0; }
.fiche-infos b { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .04em;
  color: #6b7280; margin-bottom: .15rem; }
.fiche-large { grid-column: 1 / -1; }
.fiche-position { background: #d9f2e3; border-radius: 10px; padding: .7rem .9rem; font-size: .93rem; }
.fiche-prochaine { background: #fff0dc; border-radius: 10px; padding: .7rem .9rem; font-size: .9rem; }
.fiche-h3 { margin: 0; }
.fiche-table { font-size: .84rem; }
.fiche-table .fiche-postes { white-space: normal; min-width: 200px; }
tr.fiche-actuel td { background: #d9f2e3; font-weight: 700; }
@media (max-width: 620px) {
  .dialog-card.fiche-card { padding: 1rem .8rem; }
  .fiche-entete { margin: -1rem -.8rem 0; padding: .9rem .8rem; }
  .fiche-avatar { width: 44px; height: 44px; font-size: 1rem; }
  .fiche-table { font-size: .78rem; }
  .fiche-table .fiche-postes { min-width: 150px; }
}

/* Champs figés en modification d'agent */
input:disabled, select:disabled, input[readonly] { background: #f3f4f6; color: #6b7280; cursor: not-allowed; }

#import-real-form, #import-agents-form { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.zone-suppr { margin-top: 1rem; padding-top: .8rem; border-top: 1px dashed var(--border);
  display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; font-size: .88rem; }
#import-real-form input[type=file], #import-agents-form input[type=file] { width: auto; flex: 1; min-width: 180px; }

@media (max-width: 900px) {
  .topbar { padding: .5rem .7rem; gap: .6rem; }
  .nav-btn { padding: .45rem .6rem; font-size: .85rem; }
  main { padding: 1rem .7rem 2.5rem; }
  .card { padding: .8rem .7rem; }
  table { font-size: .8rem; }
}
