/* Centrale SAV — La Centrale de l'Énergie */
:root {
  --blue: #0F4C81; --blue-dark: #0A3459; --blue-soft: #E7EFF7; --blue-softer: #F2F7FC;
  --green: #17703F; --green-soft: #E6F4EC; --green-light: #7FD3A0;
  --red: #A61B1B; --red-soft: #FDECEC; --red-line: #F2B8B8;
  --amber: #7A4300; --amber-soft: #FFF4E5; --amber-line: #F0C877;
  --purple: #5B2A86; --purple-soft: #F1E9F8; --purple-line: #D2BCE6;
  --ink: #141B24; --ink-2: #2B3644; --ink-3: #3D4B5C; --muted: #5B6675; --faint: #6B7684;
  --line: #DDE3EA; --line-2: #C9D2DC; --line-3: #EEF1F5;
  --bg: #F4F6F9; --white: #fff;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.45; }
a { color: var(--blue); } a:hover { color: var(--blue-dark); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0; }
button { font: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.boot { padding: 80px 24px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 13px; } .strong { font-weight: 600; }
.danger-text { color: var(--red); font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.span2 { grid-column: span 2; }
@media (max-width: 760px) { .grid2, .grid3 { grid-template-columns: 1fr; } .span2 { grid-column: auto; } }

/* Barre du haut */
.topbar { background: var(--blue); color: #fff; }
.topbar-in { max-width: 1320px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand:hover { color: #fff; }
.brand-name { font-weight: 700; font-size: 16px; display: block; }
.brand-sub { font-size: 12px; color: #CFE0F0; display: block; }
.nav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.nav a { color: #fff; text-decoration: none; font-size: 14px; padding: 10px 12px; border-radius: 8px; }
.nav a:hover { background: rgba(255,255,255,.10); color: #fff; }
.nav a.on { background: rgba(255,255,255,.16); font-weight: 600; }
.nav .who { font-size: 13px; color: #CFE0F0; padding: 0 6px 0 10px; }
.nav button.logout { background: none; border: 1px solid rgba(255,255,255,.35); color: #fff; border-radius: 8px; padding: 8px 12px; font-size: 13px; cursor: pointer; }
.badge-count { display: inline-block; min-width: 20px; padding: 1px 6px; margin-left: 4px; border-radius: 999px; background: #FFB547; color: #3A2400; font-size: 12px; font-weight: 700; text-align: center; }

.wrap { max-width: 1320px; margin: 0 auto; padding: 28px 24px 56px; }
.wrap-narrow { max-width: 1180px; }

/* Cartes */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.card-tight { padding: 16px 20px; }
.card-flush { padding: 0; overflow: hidden; }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.card-foot { padding: 14px 20px; font-size: 14px; color: var(--muted); }

.layout { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.layout-main { flex: 999 1 600px; min-width: 0; }
.layout-side { flex: 1 1 300px; min-width: 0; }
.layout-3 > .col-a { flex: 1 1 270px; min-width: 0; }
.layout-3 > .col-b { flex: 999 1 460px; min-width: 0; }
.layout-3 > .col-c { flex: 1 1 270px; min-width: 0; }

/* Formulaires */
.label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.input, .select, .textarea { width: 100%; height: 44px; border: 1px solid var(--line-2); border-radius: 8px; padding: 0 12px; font: inherit; font-size: 15px; color: var(--ink); background: #fff; }
.textarea { height: auto; min-height: 110px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }
.input-sm, .select-sm { height: 38px; font-size: 14px; }
.req { color: var(--red); }

.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) { .choice-grid { grid-template-columns: 1fr; } }
.choice { position: relative; display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--line-2); border-radius: 10px; padding: 14px; background: #fff; cursor: pointer; min-height: 80px; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice strong { font-size: 15px; }
.choice span { font-size: 13px; color: var(--muted); }
.choice:has(input:checked) { border: 2px solid var(--blue); background: var(--blue-softer); padding: 13px; }
.choice:has(input:checked) strong { color: var(--blue); }
.choice:has(input:focus-visible) { outline: 2px solid var(--blue); outline-offset: 2px; }

.urg { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line-2); border-radius: 10px; padding: 14px; cursor: pointer; background: #fff; }
.urg input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
.urg strong { display: block; font-size: 15px; }
.urg span { display: block; font-size: 13px; color: var(--muted); }
.urg-critique:has(input:checked) { border: 2px solid var(--red); background: var(--red-soft); padding: 13px; }
.urg-critique:has(input:checked) strong { color: var(--red); }
.urg-haute:has(input:checked) { border: 2px solid var(--amber); background: var(--amber-soft); padding: 13px; }
.urg-normale:has(input:checked) { border: 2px solid var(--blue); background: var(--blue-softer); padding: 13px; }
.urg input[type=radio] { accent-color: var(--blue); }

.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { position: relative; display: inline-flex; align-items: center; height: 40px; padding: 0 16px; border: 1px solid var(--line-2); border-radius: 999px; font-size: 14px; font-weight: 500; color: var(--ink-2); background: #fff; cursor: pointer; }
.pill input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pill:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.pill:has(input:focus-visible) { outline: 2px solid var(--blue); outline-offset: 2px; }

.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 100px; padding: 16px; border: 2px dashed #B7C3D0; border-radius: 10px; background: #F8FAFC; cursor: pointer; font-size: 14px; color: var(--ink-3); text-align: center; }
.drop.over { border-color: var(--blue); background: var(--blue-softer); }
.filelist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.filelist li { display: flex; justify-content: space-between; gap: 8px; align-items: center; background: #F8FAFC; border: 1px solid var(--line-3); border-radius: 8px; padding: 6px 10px; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 44px; padding: 0 18px; border: 1px solid var(--line-2); border-radius: 10px; background: #fff; font-size: 14px; font-weight: 600; color: var(--ink-2); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #F6F8FA; color: var(--ink); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); color: #fff; }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #105A31; color: #fff; }
.btn-danger { color: var(--red); border-color: var(--red-line); }
.btn-sm { height: 36px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-lg { height: 50px; padding: 0 26px; font-size: 15px; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 6px 4px; font-size: 14px; font-weight: 600; color: var(--blue); cursor: pointer; }
.link-btn.red { color: var(--red); }

/* Étiquettes */
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.t-critique { background: var(--red-soft); color: var(--red); }
.t-haute { background: #FFF1E0; color: var(--amber); }
.t-normale { background: #EEF2F6; color: var(--ink-3); }
.s-nouveau { background: var(--blue-soft); color: var(--blue); }
.s-qualifie { background: #E3F0FA; color: #134E7A; }
.s-en_cours { background: var(--blue); color: #fff; }
.s-attente_client, .s-attente_tiers { background: #FFF4D6; color: var(--amber); }
.s-escalade_juridique { background: var(--purple-soft); color: var(--purple); }
.s-resolu { background: var(--green-soft); color: var(--green); }
.s-cloture { background: #EEF2F6; color: var(--ink-3); }
.g-a_valider { background: var(--purple-soft); color: var(--purple); }
.g-valide { background: var(--green-soft); color: var(--green); }
.g-refuse { background: var(--red-soft); color: var(--red); }
.t-neutral { background: #EEF2F6; color: var(--ink-3); }
.t-out { background: var(--red-soft); color: var(--red); }

/* Alertes */
.alert { display: flex; gap: 12px; align-items: flex-start; border-radius: 10px; padding: 14px 16px; font-size: 14px; }
.alert-warn { background: #FFF6E5; border: 1px solid var(--amber-line); color: #5A3A00; }
.alert-info { background: var(--blue-softer); border: 1px solid #C7DAEC; color: var(--ink-2); }
.alert-danger { background: var(--red-soft); border: 1px solid var(--red-line); color: #6A1D1D; }
.alert-purple { background: var(--purple-soft); border: 1px solid var(--purple-line); color: #4A2A66; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; }
.kpi .k-label { font-size: 13px; font-weight: 600; color: var(--ink-3); }
.kpi .k-value { font-size: 32px; font-weight: 700; }
.kpi .k-sub { font-size: 13px; color: var(--muted); }
.kpi-red { background: var(--red-soft); border-color: var(--red-line); } .kpi-red .k-label, .kpi-red .k-value { color: var(--red); }
.kpi-amber { background: var(--amber-soft); border-color: var(--amber-line); } .kpi-amber .k-label, .kpi-amber .k-value { color: var(--amber); }
.kpi-purple { background: var(--purple-soft); border-color: var(--purple-line); } .kpi-purple .k-label, .kpi-purple .k-value { color: var(--purple); }

/* Tableaux */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { font-size: 14px; padding: 12px; border-bottom: 1px solid var(--line-3); white-space: nowrap; vertical-align: middle; }
.tbl tr.row-alert { background: #FFFAFA; }
.tbl tr.clickable { cursor: pointer; } .tbl tr.clickable:hover { background: #F8FAFC; }
.tbl td.wrap-cell { white-space: normal; min-width: 180px; }
.empty { padding: 28px 20px; text-align: center; color: var(--muted); font-size: 14px; }

/* Filtres */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters .input, .filters .select { height: 40px; font-size: 14px; width: auto; }
.filters .input { width: 240px; max-width: 100%; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg button { height: 38px; padding: 0 12px; border: 0; background: #fff; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.on { background: var(--blue-soft); color: var(--blue); font-weight: 600; }

/* Kanban */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.kcol { background: #EAEFF4; border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 160px; }
.kcol-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.kcard { display: block; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; text-decoration: none; color: inherit; font-size: 13px; }
.kcard:hover { border-color: var(--blue); color: inherit; }
.kcard .num { font-weight: 700; color: var(--blue); }

/* Barres */
.bar { height: 8px; background: var(--line-3); border-radius: 4px; overflow: hidden; }
.bar > div { height: 8px; background: var(--blue); border-radius: 4px; }

/* Historique */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-3); }
.timeline li:last-child { border-bottom: 0; }
.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: #8A96A3; }
.dot-note_interne { background: var(--blue); } .dot-echange_client { background: var(--green); } .dot-commentaire { background: #2E7DBF; }
.dot-geste { background: var(--purple); } .dot-statut, .dot-assignation, .dot-urgence { background: #8A96A3; }
.dot-intervention { background: #B86E00; } .dot-document { background: var(--purple); } .dot-piece_jointe { background: #4F7A99; }
.ev-head { font-size: 14px; }
.ev-body { font-size: 14px; color: var(--ink-3); white-space: pre-wrap; word-break: break-word; }
.ev-note { background: var(--blue-softer); border-radius: 8px; padding: 2px 8px; }

.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.kv > span:first-child { color: var(--muted); flex: none; }
.kv > span:last-child { text-align: right; word-break: break-word; }

.checklist { display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.checklist label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.checklist input { width: 18px; height: 18px; margin-top: 1px; flex: none; }
.checklist .done { color: var(--muted); text-decoration: line-through; }

/* Fenêtre modale */
.modal-back { position: fixed; inset: 0; background: rgba(15, 27, 40, .45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 640px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-body { padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.modal-close { background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); padding: 6px 8px; }

/* Notifications */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: calc(100vw - 32px); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.2); max-width: 420px; }
.toast-ok { background: var(--green); } .toast-err { background: var(--red); }

/* Connexion */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: #E9EEF4; }
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: 18px; box-shadow: 0 2px 12px rgba(15,40,70,.08); padding: 36px 28px; display: flex; flex-direction: column; gap: 20px; }
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.code-input { letter-spacing: 10px; text-align: center; font-size: 26px; font-weight: 700; height: 58px; }

.success-box { text-align: center; padding: 40px 24px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.ticket-number { font-size: 30px; font-weight: 700; color: var(--blue); letter-spacing: .02em; }

@media print { .topbar, #toasts { display: none; } }
