/* =====================================================================
   SIGH — Système d'Information de Gestion de l'Hébergement — IRIC
   Identité : bleu institutionnel + or (logo) · vert/orange/rouge = score
   Aucune dépendance externe. Thème clair/sombre. Impression globale.
   ===================================================================== */
:root {
  --navy: #16305C;
  --navy-deep: #0F2244;
  --gold: #C9A227;
  --gold-soft: #F3E7C2;
  --blue: #2E6DA4;
  --blue-soft: #DCE6F1;
  --bg: #F3F5F9;
  --card: #FFFFFF;
  --text: #1C2733;
  --muted: #6B7A89;
  --line: #DFE5EC;
  --red: #C0392B; --red-bg: #FDECEA;
  --green: #1E7E34; --green-bg: #E6F4EA;
  --amber: #9C6500; --amber-bg: #FFF6DC;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16,34,68,.07), 0 1px 2px rgba(16,34,68,.05);
}
html[data-theme="sombre"] {
  --navy: #0F2244; --navy-deep: #0A1830; --bg: #131B26; --card: #1B2531;
  --text: #E7ECF2; --muted: #93A2B3; --line: #2B3542;
  --blue-soft: #1F3350; --red-bg: #3A2020; --green-bg: #17311F; --amber-bg: #382C10;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; transition: background .15s, color .15s; }
a { color: var(--blue); }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 250px; flex-shrink: 0; background: var(--navy); color: #E8EEF5; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand-logo { width: 40px; height: auto; background: #fff; border-radius: 6px; padding: 2px; }
.brand-title { font-size: 18px; font-weight: 800; letter-spacing: 2px; color: #fff; }
.brand-sub { font-size: 11px; color: #AEC3D8; }
.auth-logo { width: 72px; display: block; margin: 0 auto 6px; }

.sidebar nav { padding: 10px 0; flex: 1; }
.sidebar nav a { display: flex; align-items: center; gap: 9px; padding: 9px 18px; color: #D5E1EE; text-decoration: none; border-left: 3px solid transparent; font-size: 13.5px; }
.nav-ic { font-size: 15px; width: 18px; text-align: center; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); }
.sidebar nav a.active { background: var(--navy-deep); border-left-color: var(--gold); color: #fff; font-weight: 600; }
.sidebar-foot { padding: 12px 18px 16px; border-top: 1px solid rgba(255,255,255,.12); font-size: 13px; }
.theme-toggle { width: 100%; margin-bottom: 10px; background: rgba(255,255,255,.08); color: #E8EEF5; border: 1px solid rgba(255,255,255,.18); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 12.5px; }
.theme-toggle:hover { background: rgba(255,255,255,.16); }
.userbox strong { display: block; color: #fff; }
.userbox span { color: var(--gold-soft); font-size: 11.5px; }
.logout { display: inline-block; margin-top: 8px; color: #FFB4A8; text-decoration: none; font-size: 13px; }
.logout:hover { text-decoration: underline; }

.content { flex: 1; padding: 22px 28px 50px; max-width: 1300px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.topbar h1 { font-size: 21px; margin: 0; color: var(--navy); }
html[data-theme="sombre"] .topbar h1 { color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-date { color: var(--muted); font-size: 13px; }
.print-header { display: none; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 12px; font-size: 15.5px; color: var(--navy); }
html[data-theme="sombre"] .card h2 { color: var(--gold-soft); }

.flash { padding: 11px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.flash-success { background: var(--green-bg); color: var(--green); border: 1px solid #BFE3C8; }
.flash-error   { background: var(--red-bg); color: var(--red); border: 1px solid #F2C3BD; }

.btn { display: inline-block; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--blue); background: var(--blue); color: #fff; text-decoration: none; font-size: 14px; cursor: pointer; }
.btn:hover { background: #275D8C; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #1C1500; font-weight: 600; }
.btn-gold:hover { background: #B38F20; }
.btn-outline { background: transparent; color: var(--blue); }
.btn-outline:hover { background: var(--blue-soft); }
.btn-danger { background: var(--red); border-color: var(--red); }
.btn-danger:hover { background: #A03225; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }

table.data { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.data th { background: var(--navy); color: #fff; text-align: left; font-size: 12.5px; padding: 10px 12px; font-weight: 600; white-space: nowrap; }
table.data td { padding: 9px 12px; border-top: 1px solid var(--line); font-size: 13.5px; vertical-align: middle; }
table.data tr:hover td { background: rgba(46,109,164,.05); }
tr.row-alert td:first-child { box-shadow: inset 4px 0 0 var(--red); }
tr.row-alert td { background: var(--red-bg); }
tr.row-warn td:first-child { box-shadow: inset 4px 0 0 var(--amber); }
tr.row-warn td { background: var(--amber-bg); }
tr.row-muted td { color: var(--muted); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.b-red { background: var(--red-bg); color: var(--red); }
.b-red-full { background: var(--red); color: #fff; }
.b-green { background: var(--green-bg); color: var(--green); }
.b-amber { background: var(--amber-bg); color: var(--amber); }
.b-grey { background: rgba(107,122,137,.12); color: var(--muted); }
.b-gold { background: var(--gold-soft); color: #6B5610; }
.b-blue { background: var(--blue-soft); color: var(--navy); }

/* KPI premium */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 17px; box-shadow: var(--shadow); transition: transform .12s; }
.kpi:hover { transform: translateY(-2px); }
.kpi .kpi-val { font-size: 29px; font-weight: 800; color: var(--navy); line-height: 1.1; }
html[data-theme="sombre"] .kpi .kpi-val { color: #fff; }
.kpi .kpi-label { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.kpi.kpi-alert { border-color: var(--red); background: var(--red-bg); }
.kpi.kpi-alert .kpi-val { color: var(--red); }
.kpi.kpi-warn { border-left: 4px solid var(--amber); }
.kpi.kpi-ok .kpi-val { color: var(--green); }
.kpi-link { text-decoration: none; display: block; }

/* Urgent actions */
.urgent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-bottom: 20px; }
.urgent-item { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--muted); border-radius: 10px; padding: 12px 14px; text-decoration: none; color: var(--text); box-shadow: var(--shadow); }
.urgent-item:hover { background: rgba(46,109,164,.06); }
.urgent-item.u-rouge { border-left-color: var(--red); }
.urgent-item.u-orange { border-left-color: var(--amber); }
.urgent-item.u-jaune { border-left-color: #D4AC0D; }
.urgent-emoji { font-size: 22px; }
.urgent-count { font-size: 22px; font-weight: 800; }
.urgent-label { font-size: 12.5px; color: var(--muted); }

/* Graphiques */
.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 20px; }
.chart-card canvas { max-height: 260px; }

/* Formulaires */
form.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px 18px; }
form .field { display: flex; flex-direction: column; }
form .field.wide { grid-column: 1 / -1; }
label { font-size: 12.5px; font-weight: 600; color: var(--navy); margin-bottom: 4px; }
html[data-theme="sombre"] label { color: var(--gold-soft); }
input[type=text], input[type=date], input[type=number], input[type=password], input[type=email], input[type=file], select, textarea {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: var(--card); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }
.form-actions { grid-column: 1 / -1; display: flex; gap: 10px; margin-top: 6px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; grid-column: 1/-1; }
legend { padding: 0 6px; font-weight: 700; color: var(--navy); font-size: 13px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px; }
.filters .field { display: flex; flex-direction: column; }
.filters input, .filters select { min-width: 150px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.empty { padding: 30px; text-align: center; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 7px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: 13px; }
.tabs a.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.photo-grid img { width: 100%; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.compare .col { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.compare h3 { margin-top: 0; font-size: 14px; color: var(--navy); }

.dossier-header { display: flex; gap: 18px; align-items: center; margin-bottom: 18px; }
.dossier-photo { width: 96px; height: 96px; border-radius: 12px; object-fit: cover; border: 2px solid var(--line); background: var(--blue-soft); }
.dossier-name { font-size: 20px; font-weight: 800; color: var(--navy); }
html[data-theme="sombre"] .dossier-name { color: #fff; }
.dossier-meta { color: var(--muted); font-size: 13px; }

.recu-box { max-width: 480px; margin: 0 auto; border: 2px solid var(--navy); border-radius: 14px; padding: 24px; background: var(--card); }
.recu-box .recu-head { display: flex; align-items: center; gap: 12px; border-bottom: 2px solid var(--gold); padding-bottom: 12px; margin-bottom: 14px; }
.recu-box .recu-head img { width: 50px; }
.recu-line { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.recu-total { font-size: 18px; font-weight: 800; color: var(--navy); text-align: right; margin-top: 10px; }
.recu-qr { text-align: center; margin-top: 16px; }
.recu-token { text-align: center; font-size: 11px; color: var(--muted); margin-top: 4px; letter-spacing: 1px; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .sidebar nav { display: flex; flex-wrap: wrap; }
  .sidebar nav a { border-left: none; border-bottom: 3px solid transparent; }
  .sidebar nav a.active { border-bottom-color: var(--gold); }
  .content { padding: 16px; }
  table.data { display: block; overflow-x: auto; }
  .compare { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ===================== IMPRESSION ===================== */
@media print {
  .sidebar, .topbar, .no-print, .filters, .toolbar form, .theme-toggle { display: none !important; }
  .print-header { display: flex !important; align-items: center; gap: 14px; border-bottom: 3px solid var(--navy); padding-bottom: 10px; margin-bottom: 18px; }
  .print-header img { width: 55px; }
  .layout { display: block; }
  .content { padding: 0; max-width: 100%; }
  body { background: #fff; color: #000; }
  .card, table.data, .recu-box { box-shadow: none; border: 1px solid #999; }
  a { color: #000; text-decoration: none; }
  table.data th { background: #EEE !important; color: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .kpi, .urgent-item { break-inside: avoid; }
}

/* ===================== Connexion / installeur ===================== */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, var(--navy), var(--navy-deep)); }
.auth-card { background: #fff; border-radius: 16px; padding: 34px 36px; width: 400px; max-width: 92vw; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.auth-card .brand-sub { text-align: center; color: var(--muted); margin-bottom: 22px; font-size: 13px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.steps { display: flex; gap: 6px; margin-bottom: 18px; justify-content: center; flex-wrap: wrap; }
.step { padding: 4px 10px; border-radius: 999px; background: #ECEFF3; color: var(--muted); font-size: 11px; font-weight: 600; }
.step.on { background: var(--gold); color: #1C1500; }
