/* Nexsus 18-112 — thème console opérationnelle */
:root {
  --bg: #0b1424;
  --bg-2: #101c31;
  --panel: #14223a;
  --panel-2: #1a2b48;
  --line: #24385a;
  --line-2: #2f4a75;
  --text: #e6edf7;
  --muted: #8ea2c0;
  --accent: #d6262f;
  --accent-2: #ff4b55;
  --blue: #2f6fd6;
  --ok: #2e9e4f;
  --warn: #e0b000;
  --orange: #e8740c;
  --radius: 6px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.4 var(--font); }
a { color: #7fb0ff; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 8px; }
.right { margin-left: auto; }

/* ---------- barre supérieure */
.topbar {
  height: 52px; display: flex; align-items: center; gap: 16px; padding: 0 16px;
  background: linear-gradient(90deg, #081022, #0f2147); border-bottom: 2px solid var(--accent);
}
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 6px; background: var(--accent); display: grid; place-items: center;
  font-weight: 800; font-size: 13px; letter-spacing: -.5px;
}
.brand b { font-size: 16px; letter-spacing: .5px; }
.brand span { color: var(--muted); font-size: 12px; display: block; }
.tabs { display: flex; gap: 2px; }
.tab {
  background: none; border: 0; color: var(--muted); padding: 8px 14px; border-radius: var(--radius);
  font: inherit; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); background: rgba(255,255,255,.05); }
.tab.active { color: #fff; background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--accent); }
.clock { font-family: var(--mono); font-size: 18px; letter-spacing: 1px; }
.kpi { display: flex; gap: 6px; }
.kpi div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 3px 10px; text-align: center; }
.kpi b { display: block; font-size: 15px; line-height: 1.1; }
.kpi span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

/* ---------- formulaires & boutons */
button, .btn {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: var(--radius); padding: 7px 12px; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
}
button:hover, .btn:hover { border-color: #4d6ea3; background: #213659; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-2); }
button.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
button.ghost { background: transparent; }
button.sm { padding: 4px 8px; font-size: 12px; }
button.danger { color: #ff8a90; border-color: #6b2a33; }

label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--line-2);
  border-radius: var(--radius); padding: 7px 9px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47,111,214,.6); outline-offset: -1px; border-color: var(--blue); }
textarea { resize: vertical; min-height: 64px; }
.field { margin-bottom: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.check { display: flex; gap: 6px; align-items: center; color: var(--text); font-size: 13px; margin: 0; cursor: pointer; }
.check input { width: auto; }

/* ---------- panneaux */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--line);
  font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600;
}
.panel-body { padding: 12px; }
.section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin: 14px 0 6px; font-weight: 600; }

.badge {
  display: inline-block; padding: 1px 7px; border-radius: 3px; font-size: 11px; font-weight: 700;
  letter-spacing: .3px; color: #fff; background: #4a5a74; white-space: nowrap;
}
.badge.P1 { background: var(--accent); }
.badge.P2 { background: var(--orange); }
.badge.P3 { background: #4c7bc2; }
.fam { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border-radius: 3px; border: 1px solid; }
.fam.SUAP { color: #ff8a90; border-color: #7a2a33; }
.fam.INC  { color: #ffb15c; border-color: #7a4a1a; }
.fam.AVP  { color: #ffd65c; border-color: #6d5a14; }
.fam.DIV  { color: #7fd3a0; border-color: #1e5a39; }
.fam.APP  { color: #fff; border-color: var(--accent); background: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .4; } }

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.list td { padding: 8px 10px; border-bottom: 1px solid rgba(36,56,90,.6); vertical-align: middle; }
table.list tr:hover td { background: rgba(255,255,255,.02); }
table.list input, table.list select { padding: 4px 6px; }

/* ---------- modales */
.modal-back { position: fixed; inset: 0; background: rgba(3,8,18,.7); display: grid; place-items: center; z-index: 2000; padding: 16px; }
.modal { width: min(720px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal header { display: flex; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); gap: 10px; position: sticky; top: 0; background: var(--panel); z-index: 1; }
.modal header h3 { font-size: 16px; }
.modal .body { padding: 16px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--panel); }

/* ---------- notifications */
#toasts { position: fixed; top: 62px; right: 14px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; width: 340px; }
.toast { background: var(--panel-2); border: 1px solid var(--line-2); border-left: 4px solid var(--blue); border-radius: var(--radius); padding: 10px 12px; box-shadow: 0 8px 24px rgba(0,0,0,.4); animation: slide .2s ease-out; cursor: pointer; }
.toast.urgence { border-left-color: var(--accent); background: #3a1018; animation: slide .2s ease-out, flash .6s steps(2) infinite; }
.toast.appel { border-left-color: var(--accent); }
.toast.bilan { border-left-color: var(--ok); }
.toast.radio { border-left-color: var(--warn); }
.toast small { color: var(--muted); display: block; font-size: 11px; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
@keyframes flash { 50% { background: #6b1420; } }

/* ---------- carte */
.map { background: #0f2a3d; }
.leaflet-container { background: #143247; font-family: var(--font); }
.map-label { color: rgba(220,235,255,.55); font-size: 13px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; white-space: nowrap; text-shadow: 0 1px 3px #000; }
.veh-icon { display: flex; align-items: center; gap: 4px; }
.veh-icon .pin { width: 14px; height: 14px; border-radius: 3px; border: 2px solid #fff; box-shadow: 0 0 0 1px #000; }
.veh-icon .tag { background: rgba(8,14,28,.88); color: #fff; padding: 1px 5px; border-radius: 3px; font-size: 11px; font-weight: 600; white-space: nowrap; border: 1px solid rgba(255,255,255,.15); }
.op-icon { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--accent); border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.6); display: grid; place-items: center; }
.op-icon span { transform: rotate(45deg); font-size: 10px; font-weight: 800; color: #fff; }
.op-icon.sel { box-shadow: 0 0 0 4px rgba(255,255,255,.5), 0 2px 8px rgba(0,0,0,.6); }
.centre-icon { width: 22px; height: 22px; border-radius: 4px; background: #fff; color: var(--accent); font-weight: 900; font-size: 11px; display: grid; place-items: center; border: 2px solid var(--accent); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel-2); color: var(--text); }

/* ---------- connexion */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 50% -10%, #1b3466, var(--bg)); }
.login { width: min(380px, 100%); }
.login .brand { justify-content: center; margin-bottom: 18px; }
.login .brand .logo { width: 44px; height: 44px; font-size: 16px; }
.login .brand b { font-size: 22px; }
.error { color: #ff8a90; font-size: 13px; min-height: 18px; }

/* ---------- responsive */
@media (max-width: 760px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 8px 16px; gap: 8px; }
  .tabs { overflow-x: auto; max-width: 100%; }
  .kpi, .clock { display: none; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  #toasts { width: calc(100% - 28px); }
}

@media print {
  body { background: #fff; color: #000; }
  .no-print { display: none !important; }
}

/* demande de parole (codes 3 / 4) */
.parole { animation: parole 1s steps(2) infinite; }
.parole.urgente { animation-duration: .5s; }
@keyframes parole { 50% { background: rgba(224,176,0,.25); } }
.parole.urgente { --pc: rgba(214,38,47,.4); }
.parole.urgente { animation-name: paroleU; }
@keyframes paroleU { 50% { background: rgba(214,38,47,.4); } }

/* pastilles de statut (couleurs du synoptique CODIS) */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 700;
  border: 1px solid rgba(0,0,0,.35); white-space: nowrap; cursor: pointer; line-height: 1.5; }
.pill.sm { font-size: 11px; padding: 1px 7px; }
.pill:hover { filter: brightness(1.12); }
.badge-engin { display: inline-flex; border-radius: 4px; overflow: hidden; font-size: 11px; font-weight: 800; cursor: pointer; border: 1px solid rgba(0,0,0,.4); }
.badge-engin .cs { padding: 3px 7px; color: #fff; }
.badge-engin .en { padding: 3px 9px; }
.cards4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kcard { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: flex; gap: 12px; align-items: center; }
.kcard .ico { width: 38px; height: 38px; border-radius: 8px; display: grid; place-items: center; font-size: 18px; background: var(--panel-2); }
.kcard b { font-size: 22px; display: block; }
.kcard span { color: var(--muted); font-size: 12px; }
.form-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 12px; }
.form-card h4 { font-size: 13px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.form-card .in { padding: 12px; }
@media (max-width: 760px) { .cards4 { grid-template-columns: 1fr 1fr; } }

/* Liste ordonnée de valeurs (référentiels : engins proposés d'une nature…) */
.chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chips .chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 8px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 12px; font-size: 12px; white-space: nowrap; }
.chips .chip button { padding: 0 4px; border: 0; background: none; color: inherit; opacity: .6; cursor: pointer; font-size: 11px; }
.chips .chip button:hover { opacity: 1; }
.chips select { width: auto; padding: 2px 6px; font-size: 12px; }
