/* =====================================================================
   Sentinelle 7G — Design system « Brutalist Pop »
   Jaune vif + bordures noires épaisses + ombres dures. 2 thèmes.
   ===================================================================== */
:root {
  --yellow: #FFD400;
  --pink:   #FF5C8A;
  --blue:   #3D9BFF;
  --green:  #21BA45;
  --red:    #FF4136;
  --orange: #FF851B;
  --purple: #B10DC9;

  --bg:      #F5F1E8;
  --surface: #FFFFFF;
  --surface2:#FBF8F1;
  --ink:     #111111;
  --ink-soft:#555555;
  --muted:   #8a8a8a;
  --line:    #111111;
  --shadow:  5px 5px 0 #111111;
  --shadow-sm: 3px 3px 0 #111111;
  --radius:  8px;
}
html[data-theme="dark"] {
  --bg:      #17151C;
  --surface: #221F29;
  --surface2:#2A2732;
  --ink:     #F5F1E8;
  --ink-soft:#C9C4B8;
  --muted:   #8d8898;
  --line:    #F5F1E8;
  --shadow:  5px 5px 0 #000000;
  --shadow-sm: 3px 3px 0 #000000;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
}
a { color: inherit; text-decoration: none; border-bottom: 2px solid var(--yellow); }
a:hover { background: var(--yellow); color: #111; }

::selection { background: var(--yellow); color: #111; }

h1, h2, h3 { letter-spacing: -.3px; }

/* ===== LOGIN ===== */
.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  background-image: radial-gradient(var(--yellow) 2.5px, transparent 2.5px);
  background-size: 34px 34px;
  padding: 20px;
}
.login-card {
  background: var(--surface); padding: 36px;
  border: 4px solid var(--line); box-shadow: 9px 9px 0 var(--yellow), 9px 9px 0 4px var(--line);
  width: 100%; max-width: 400px; border-radius: var(--radius);
}
.login-card h1 { margin: 0 0 2px; font-size: 30px; text-transform: uppercase; }
.login-card h1 .flame { color: var(--red); }
.login-card .subtitle { color: var(--ink-soft); margin: 0 0 24px; font-size: 13px; font-weight: 600; }

/* ===== APP SHELL ===== */
.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 3px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { padding: 18px 16px; border-bottom: 3px solid var(--line); background: var(--yellow); color: #111; }
.brand h2 { margin: 0; font-size: 19px; text-transform: uppercase; letter-spacing: -.5px; }
.brand .brand-sub { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 2px; }
.sidebar nav { padding: 12px 10px; flex: 1; }
.sidebar nav .nav-group { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 2px; color: var(--muted); margin: 14px 8px 4px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 9px; padding: 9px 10px; margin: 3px 0;
  font-size: 14px; font-weight: 700; border: 2px solid transparent; border-radius: 6px; cursor: pointer;
}
.sidebar nav a:hover { border-color: var(--line); background: var(--surface2); }
.sidebar nav a.active { background: var(--yellow); color: #111; border-color: var(--line); box-shadow: var(--shadow-sm); }
.sidebar nav a .ico { width: 22px; text-align: center; }
.user-box { padding: 12px 14px; border-top: 3px solid var(--line); font-size: 13px; }
.user-box .name { font-weight: 800; }
.user-box .role { display: inline-block; font-size: 10px; font-weight: 800; text-transform: uppercase; background: var(--pink); color: #111; border: 2px solid var(--line); padding: 1px 8px; border-radius: 20px; margin: 4px 0 8px; }

/* topbar */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 12px 22px;
  background: var(--surface); border-bottom: 3px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.topbar .search-wrap { position: relative; flex: 1; max-width: 420px; }
.topbar input[type=search] { margin: 0; }
.search-results {
  position: absolute; top: 100%; left: 0; right: 0; margin-top: 6px; z-index: 60;
  background: var(--surface); border: 3px solid var(--line); box-shadow: var(--shadow); border-radius: 6px;
  max-height: 420px; overflow-y: auto;
}
.search-results .sr-group { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; padding: 8px 12px 2px; color: var(--muted); }
.search-results .sr-item { display: block; padding: 8px 12px; font-size: 13px; font-weight: 600; border-bottom: 1px solid var(--surface2); cursor: pointer; }
.search-results .sr-item:hover { background: var(--yellow); color: #111; }
.iconbtn {
  position: relative; background: var(--surface); border: 3px solid var(--line); border-radius: 8px;
  font-size: 17px; padding: 6px 11px; cursor: pointer; box-shadow: var(--shadow-sm); color: var(--ink);
}
.iconbtn:hover { transform: translate(1px,1px); box-shadow: 2px 2px 0 var(--line); }
.iconbtn .bubble {
  position: absolute; top: -8px; right: -8px; background: var(--red); color: #fff;
  border: 2px solid var(--line); border-radius: 20px; font-size: 10px; font-weight: 800; padding: 1px 6px;
}
.notif-panel {
  position: absolute; right: 22px; top: 62px; z-index: 70; width: 340px;
  background: var(--surface); border: 3px solid var(--line); box-shadow: var(--shadow); border-radius: var(--radius);
  padding: 12px;
}
.notif-panel h4 { margin: 0 0 8px; text-transform: uppercase; font-size: 12px; letter-spacing: 1px; }
.notif-item { display: flex; gap: 8px; align-items: center; padding: 7px 8px; font-size: 13px; font-weight: 600; border: 2px solid var(--line); border-radius: 6px; margin-bottom: 6px; background: var(--surface2); cursor: pointer; }
.notif-item:hover { background: var(--yellow); color: #111; }

#view { padding: 22px 26px; }

/* ===== HEADERS / KPI / CARDS ===== */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { margin: 0; font-size: 26px; text-transform: uppercase; }
.page-header .crumbs { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 4px; }
.page-header .crumbs a { border-bottom-color: var(--muted); }

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi {
  background: var(--surface); padding: 14px 16px; border: 3px solid var(--line);
  box-shadow: var(--shadow); border-radius: var(--radius); position: relative; overflow: hidden;
}
.kpi::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 6px; background: var(--yellow); }
.kpi.pink::before { background: var(--pink); }
.kpi.blue::before { background: var(--blue); }
.kpi.green::before { background: var(--green); }
.kpi.red::before { background: var(--red); }
.kpi.orange::before { background: var(--orange); }
.kpi .label { font-size: 10px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 1.5px; font-weight: 800; margin: 4px 0 2px; }
.kpi .value { font-size: 30px; font-weight: 900; }

.card {
  background: var(--surface); border: 3px solid var(--line); box-shadow: var(--shadow);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px;
}
.card h3 {
  margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px;
  display: inline-block; background: var(--yellow); color: #111; padding: 3px 10px;
  border: 2px solid var(--line); border-radius: 4px; box-shadow: var(--shadow-sm);
}

/* ===== TABLES ===== */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 11px; text-align: left; font-size: 13px; border-bottom: 2px solid var(--surface2); }
th { font-weight: 800; font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--ink-soft); border-bottom: 3px solid var(--line); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface2); }
.table-wrap { overflow-x: auto; }

/* ===== FORMS ===== */
label { display: block; font-size: 11px; color: var(--ink-soft); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 1px; font-weight: 800; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 3px solid var(--line); border-radius: 6px;
  font-size: 14px; font-family: inherit; font-weight: 600; background: var(--surface); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; box-shadow: var(--shadow-sm); background: var(--surface2); }
.form-row { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

button {
  background: var(--yellow); color: #111; border: 3px solid var(--line); padding: 9px 16px;
  border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 800; box-shadow: var(--shadow-sm);
  font-family: inherit;
}
button:hover { transform: translate(1px,1px); box-shadow: 2px 2px 0 var(--line); }
button:active { transform: translate(3px,3px); box-shadow: none; }
button.secondary { background: var(--surface); color: var(--ink); }
button.pink { background: var(--pink); }
button.blue { background: var(--blue); }
button.green { background: var(--green); }
button.danger { background: var(--red); color: #fff; }
button.small { padding: 5px 10px; font-size: 12px; box-shadow: 2px 2px 0 var(--line); }
button:disabled { opacity: .5; cursor: not-allowed; }

/* ===== BADGES ===== */
.badge {
  display: inline-block; padding: 2px 9px; border: 2px solid var(--line); border-radius: 20px;
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: #111; background: var(--surface2);
}
.badge.ok { background: var(--green); }
.badge.warn { background: var(--orange); }
.badge.danger { background: var(--red); color: #fff; }
.badge.info { background: var(--blue); }
.badge.grey { background: var(--surface2); color: var(--ink); }
.badge.yellow { background: var(--yellow); }
.badge.pink { background: var(--pink); }

/* ===== HIÉRARCHIE PARC ===== */
.batiment-block { background: var(--surface); border: 3px solid var(--line); box-shadow: var(--shadow); border-radius: var(--radius); margin-bottom: 18px; overflow: hidden; }
.batiment-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--yellow); color: #111; border-bottom: 3px solid var(--line); flex-wrap: wrap; }
.batiment-head h3 { margin: 0; font-size: 16px; text-transform: uppercase; }
.batiment-head .usage { font-size: 10px; font-weight: 800; background: var(--surface); border: 2px solid var(--line); padding: 2px 8px; border-radius: 20px; text-transform: uppercase; }
.batiment-head .actions { margin-left: auto; display: flex; gap: 6px; }
.batiment-head .actions button { box-shadow: none; padding: 4px 9px; font-size: 12px; }
.niveau-block { border-top: 2px solid var(--surface2); }
.niveau-head { display: flex; align-items: center; gap: 8px; padding: 7px 16px; background: var(--surface2); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.5px; }
.niveau-head .count { font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--muted); }
.niveau-head button { margin-left: auto; }
.equip-row { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-top: 2px solid var(--surface2); cursor: pointer; font-size: 13px; flex-wrap: wrap; font-weight: 600; }
.equip-row:hover { background: var(--surface2); }
.equip-row .num { font-weight: 900; min-width: 80px; }
.equip-row .loc { color: var(--muted); font-size: 12px; }
.equip-row .right-side { margin-left: auto; display: flex; gap: 6px; align-items: center; }

/* ===== VISITE TERRAIN ===== */
.visite-equip {
  background: var(--surface); border: 3px solid var(--line); border-left-width: 10px;
  padding: 12px 14px; margin-bottom: 10px; border-radius: 8px; cursor: pointer; box-shadow: var(--shadow-sm);
}
.visite-equip:hover { transform: translate(1px,1px); box-shadow: 2px 2px 0 var(--line); }
.visite-equip.done.conforme { border-left-color: var(--green); }
.visite-equip.done.anomalie { border-left-color: var(--orange); }
.visite-equip.done.a_remplacer { border-left-color: var(--purple); }
.visite-equip.done.hors_service { border-left-color: var(--red); }
.visite-equip.done.remplace { border-left-color: var(--blue); }
.visite-equip.done.absent { border-left-color: var(--muted); }
.quick-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.visite-equip .title { font-weight: 800; }
.visite-equip .sub { font-size: 12px; color: var(--ink-soft); }

.anomalie-pill {
  display: inline-block; padding: 5px 11px; margin: 4px 4px 0 0; border: 2px solid var(--line);
  border-radius: 18px; font-size: 12px; font-weight: 700; cursor: pointer; user-select: none; background: var(--surface2); color: var(--ink);
}
.anomalie-pill.selected { background: var(--red); color: #fff; }
.anomalie-pill.critique { border-color: var(--red); }
.anomalie-pill.majeure { border-color: var(--orange); }

/* ===== CHECKLIST ===== */
.point-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 2px solid var(--surface2); }
.point-row .lib { flex: 1; font-size: 13px; font-weight: 600; }
.point-row .lib .aide { display: block; font-size: 11px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.point-row .lib .crit { color: var(--red); font-weight: 900; font-size: 9px; text-transform: uppercase; margin-left: 6px; letter-spacing: 1px; }
.point-btns { display: flex; gap: 4px; flex-shrink: 0; }
.point-btns button { padding: 4px 9px; font-size: 12px; background: var(--surface2); color: var(--ink); box-shadow: none; }
.point-btns button.sel-ok { background: var(--green); color: #111; }
.point-btns button.sel-nok { background: var(--red); color: #fff; }
.point-btns button.sel-na { background: var(--ink); color: var(--bg); }
.ops-box { background: var(--surface2); border: 3px dashed var(--line); border-radius: 8px; padding: 10px 12px; margin: 12px 0; }
.ops-box label.op { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; text-transform: none; letter-spacing: 0; font-weight: 600; margin: 6px 0; cursor: pointer; }
.ops-box label.op input { width: auto; margin-top: 2px; }
.ops-box .due { color: var(--red); font-weight: 900; font-size: 11px; }
.ops-box .src { color: var(--muted); font-size: 11px; }

/* photos */
.photo-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.photo-thumb { position: relative; width: 86px; height: 66px; border: 3px solid var(--line); border-radius: 6px; overflow: hidden; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb .del { position: absolute; top: 0; right: 0; background: var(--red); color: #fff; border: none; border-left: 2px solid var(--line); border-bottom: 2px solid var(--line); font-size: 11px; padding: 1px 6px; cursor: pointer; box-shadow: none; border-radius: 0; }

/* signature */
.sig-canvas { background: #fff; border: 3px solid var(--line); border-radius: 6px; touch-action: none; width: 100%; max-width: 420px; }
.sig-box { border: 3px solid var(--line); border-radius: 8px; padding: 10px; background: var(--surface2); }
.sig-done { border: 3px solid var(--green); border-radius: 8px; padding: 8px 12px; font-weight: 700; background: var(--surface2); }

/* ===== ÉCHÉANCIER / RÉFÉRENTIEL / STATS ===== */
.late { color: var(--red); font-weight: 900; }
.ref-famille h2 { font-size: 18px; text-transform: uppercase; background: var(--pink); color: #111; display: inline-block; padding: 3px 12px; border: 3px solid var(--line); border-radius: 6px; box-shadow: var(--shadow-sm); }
.ref-src { font-size: 11px; color: var(--muted); font-weight: 600; }
.help-inline { font-size: 12px; color: var(--muted); font-weight: 500; }

.bar-row { display: flex; align-items: center; gap: 10px; margin: 7px 0; font-size: 13px; font-weight: 700; }
.bar-row .bar-label { width: 190px; flex-shrink: 0; text-align: right; font-size: 12px; }
.bar-row .bar-track { flex: 1; background: var(--surface2); border: 2px solid var(--line); border-radius: 4px; height: 22px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; background: var(--yellow); border-right: 2px solid var(--line); min-width: 2px; }
.bar-row .bar-val { width: 46px; font-weight: 900; }

/* ===== CALENDRIER ===== */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head { font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: 1px; text-align: center; padding: 4px; }
.cal-cell { min-height: 86px; border: 2px solid var(--line); border-radius: 6px; background: var(--surface); padding: 4px 6px; font-size: 11px; }
.cal-cell.other { opacity: .35; }
.cal-cell.today { background: var(--yellow); color: #111; }
.cal-cell .d { font-weight: 900; font-size: 12px; }
.cal-ev { display: block; margin-top: 3px; padding: 2px 5px; border: 2px solid var(--line); border-radius: 4px; background: var(--blue); color: #111; font-weight: 700; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cal-ev.terminee { background: var(--green); }
.cal-ev.en_cours { background: var(--orange); }

/* ===== TABS internes ===== */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: var(--surface); }
.tabs button.active { background: var(--yellow); }

/* ===== MODAL / TOAST ===== */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 14px; }
.modal {
  background: var(--surface); border: 4px solid var(--line); box-shadow: 8px 8px 0 var(--yellow), 8px 8px 0 4px var(--line);
  border-radius: var(--radius); padding: 22px; max-width: 640px; width: 100%; max-height: 92vh; overflow-y: auto;
}
.modal h3 { margin-top: 0; text-transform: uppercase; font-size: 16px; border-bottom: 3px solid var(--line); padding-bottom: 8px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

#toasts { position: fixed; bottom: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--surface); border: 3px solid var(--line); box-shadow: var(--shadow); border-radius: 8px; padding: 10px 16px; font-weight: 700; font-size: 14px; }
.toast.ok { border-left: 10px solid var(--green); }
.toast.err { border-left: 10px solid var(--red); }
.toast.warn { border-left: 10px solid var(--orange); }

.offline-banner {
  background: var(--orange); color: #111; border-bottom: 3px solid var(--line);
  padding: 6px 20px; font-weight: 800; font-size: 13px; display: none;
}
.offline-banner.show { display: block; }

/* ===== PLANCHE QR (impression) ===== */
.qr-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.qr-label { border: 3px solid #111; border-radius: 8px; padding: 10px; text-align: center; background: #fff; color: #111; page-break-inside: avoid; }
.qr-label .num { font-weight: 900; font-size: 15px; }
.qr-label .typ { font-size: 11px; font-weight: 700; }
.qr-label .loc { font-size: 10px; color: #555; }
.qr-label svg { width: 110px; height: 110px; }

@media print {
  .sidebar, .topbar, .page-header button, .no-print, #toasts, .offline-banner { display: none !important; }
  .app-shell { display: block; }
  #view { padding: 0; }
  body { background: #fff; }
  .card { border: none; box-shadow: none; }
}

/* ===== MISC ===== */
.flex { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.right { margin-left: auto; }
.muted { color: var(--muted); }
.empty { text-align: center; padding: 40px; color: var(--muted); font-weight: 700; }
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.toolbar input[type=search] { max-width: 280px; }
.toolbar select { max-width: 230px; width: auto; }

/* responsive */
.menu-toggle { display: none; }
@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 0; left: -280px; height: 100vh; width: 260px; transition: left .18s; z-index: 90; }
  .sidebar.open { left: 0; }
  .menu-toggle { display: inline-block; }
  #view { padding: 14px; }
  .topbar { padding: 10px 12px; }
  .bar-row .bar-label { width: 110px; }
}
