/* swarm.css — CleanSwarm (mêmes couleurs et polices que le tableau de bord d'Arthur et le Startup Lab) */
:root {
  --bg: #f6f5f2; --card: #ffffff; --ink: #1d1d1f; --muted: #6e6e73; --faint: #a1a1a6; --line: #e7e5e0; --line2: #efede8;
  --accent: #2f5bea; --accent-soft: #e8eefd; --warn: #c2410c; --warn-soft: #fff1e8; --ok: #15803d; --ok-soft: #e7f6ec; --bad: #b91c1c;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace; --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #16171a; --card: #1f2024; --ink: #ececee; --muted: #9a9aa2; --faint: #6b6b73; --line: #2e2f35; --line2: #27282d; --accent: #7c9bff; --accent-soft: #252c44; --warn: #fb923c; --warn-soft: #3a2a1f; --ok: #4ade80; --ok-soft: #17301f; --bad: #f87171; --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 13.5px/1.45 Inter, system-ui, sans-serif; -webkit-font-smoothing: antialiased; overflow: hidden; }
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select { background: var(--card); border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; outline: none; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=number] { font-family: var(--mono); font-size: 12.5px; text-align: right; }
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 7px; padding: 6px 11px; cursor: pointer; font-weight: 500; white-space: nowrap; color: var(--ink); display: inline-block; }
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger, .menu a.danger { color: var(--bad); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.icon-btn { width: 30px; height: 30px; border: 1px solid var(--line); background: var(--card); border-radius: 7px; cursor: pointer; font-size: 15px; display: grid; place-items: center; }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.nolog, .loading { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.loading { position: fixed; inset: 0; z-index: 50; background: var(--bg); color: var(--muted); gap: 8px; grid-auto-flow: row; align-content: center; justify-items: center; }
.spin { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.nolog-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 32px; max-width: 380px; text-align: center; box-shadow: var(--shadow); }
.nolog-card h1 { font-family: Fraunces, Georgia, serif; font-weight: 600; margin: 8px 0; }
.mark { font-size: 32px; }

.app { display: grid; grid-template-rows: auto 1fr; height: 100vh; }
.bar { display: flex; align-items: center; gap: 12px; padding: 7px 14px; background: var(--card); border-bottom: 1px solid var(--line); z-index: 20; }
.back { color: var(--muted); font-size: 18px; padding: 2px 6px; border-radius: 6px; }
.back:hover { background: var(--line2); color: var(--ink); }
.brand { font-family: Fraunces, Georgia, serif; font-weight: 600; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.brand .muted { font-weight: 500; font-size: 14px; font-family: Inter, system-ui, sans-serif; }
.sep { width: 1px; height: 22px; background: var(--line); }
.scen { display: flex; align-items: center; gap: 6px; } .scen select { max-width: 200px; } .scen input { width: 190px; }
.bar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: 36px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.14); padding: 6px; min-width: 230px; z-index: 40; }
.menu a, .menu label { display: block; padding: 7px 10px; border-radius: 6px; color: var(--ink); cursor: pointer; font-size: 13px; }
.menu a:hover, .menu label:hover { background: var(--line2); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

.work { display: grid; grid-template-columns: 270px minmax(0, 1fr) 340px; min-height: 0; min-width: 0; overflow: hidden; }
.side { background: var(--card); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.side.left { border-right: 1px solid var(--line); } .side.right { border-left: 1px solid var(--line); }
.panel-h { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.panel-h h3, .sec h4, .kv-h { margin: 0; font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.params { overflow: auto; flex: 1; padding: 4px 0 20px; }
.sec { border-bottom: 1px solid var(--line2); }
.sec > summary { padding: 9px 12px; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary::after { content: '›'; color: var(--faint); transform: rotate(90deg); transition: .15s; }
.sec[open] > summary::after { transform: rotate(-90deg); }
.sec .body { padding: 2px 12px 10px; }
.field { display: grid; grid-template-columns: 1fr 92px; align-items: center; gap: 8px; padding: 3px 0; }
.field label { font-size: 12.5px; } .field label small { display: block; color: var(--faint); font-size: 11px; }
.field .unit { display: flex; align-items: center; gap: 4px; } .field .unit input, .field .unit select { width: 100%; min-width: 0; } .field .unit span { font-size: 11px; color: var(--faint); min-width: 28px; }
.note { background: var(--line2); border-radius: 8px; padding: 8px 10px; font-size: 12px; color: var(--muted); margin: 8px 0; }
.note.warn { background: var(--warn-soft); color: var(--warn); }

.center { display: grid; grid-template-rows: auto 1fr auto; min-height: 0; background: #cfe3f5; }
.toolbar, .simbar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.simbar { border-bottom: 0; border-top: 1px solid var(--line); }
.sp { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--card); }
.seg button { border: 0; background: none; padding: 4px 9px; cursor: pointer; font-size: 12.5px; color: var(--muted); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; } .seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.seg.toggles label { padding: 4px 8px; font-size: 12.5px; color: var(--muted); display: flex; gap: 4px; align-items: center; border-right: 1px solid var(--line); cursor: pointer; } .seg.toggles label:last-child { border-right: 0; }
select.mini { padding: 4px 6px; font-size: 12.5px; }
.viewport { position: relative; min-height: 200px; overflow: hidden; } .viewport canvas { display: block; }
.clock { font-family: var(--mono); font-weight: 500; font-size: 13px; padding: 3px 8px; background: var(--line2); border-radius: 6px; min-width: 70px; text-align: center; }
.phase { font-size: 12.5px; color: var(--muted); }
@media (min-width: 900px) { .simbar { flex-wrap: nowrap; } .simbar .phase, .simbar #simNote { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .simbar .phase { flex: 0 1 auto; } .simbar #simNote { flex: 0 1 auto; } .simbar .sp { min-width: 4px; } }
.lbl { font: 11px/1.2 var(--mono); color: #1d1d1f; background: rgba(255,255,255,.85); padding: 2px 5px; border-radius: 4px; border: 1px solid rgba(0,0,0,.12); white-space: nowrap; }
.lbl.rob { padding-bottom: 4px; } .lbl.rob.sel { border-color: #f59e0b; box-shadow: 0 0 0 2px rgba(245,158,11,.35); }
.lbl .bat { height: 3px; background: #22c55e; border-radius: 2px; margin-top: 2px; }
.lbl.veh { font-family: Inter, system-ui, sans-serif; font-weight: 600; }

.tabs2 { display: flex; gap: 2px; padding: 8px 10px 0; border-bottom: 1px solid var(--line); }
.tabs2 button { border: 0; background: none; padding: 6px 10px; cursor: pointer; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 13px; }
.tabs2 button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabpane { padding: 10px 12px; overflow: auto; flex: 1; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.kpi .l { line-height: 1.25; }
.kpi { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.kpi .n { font-family: var(--mono); font-size: 16px; font-weight: 500; line-height: 1.15; } .kpi .l { color: var(--muted); font-size: 10.5px; margin-top: 1px; }
.kpi.warn .n { color: var(--warn); } .kpi.ok .n { color: var(--ok); }
.big { grid-column: span 3; display: grid; grid-template-columns: 1fr auto; align-items: center; }
.big .n { font-size: 22px; } .progress { height: 8px; background: var(--line2); border-radius: 4px; overflow: hidden; margin-top: 6px; grid-column: span 2; } .progress i { display: block; height: 100%; background: var(--ok); transition: width .3s; }
.chart { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; margin-bottom: 10px; }
.chart h4 { margin: 0 0 2px; font-size: 11px; color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; }
.chart canvas { width: 100%; height: 120px; display: block; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 12.5px; margin: 4px 0 10px; } .kv b { font-family: var(--mono); font-weight: 500; }
.kv-h { margin: 10px 0 4px; }
.bars { display: grid; gap: 4px; margin-bottom: 10px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 60px; gap: 8px; align-items: center; font-size: 12px; }
.bar-row .meter { height: 7px; background: var(--line2); border-radius: 4px; overflow: hidden; } .bar-row .meter i { display: block; height: 100%; background: var(--accent); }
.bar-row b { font-family: var(--mono); font-weight: 500; text-align: right; }
.robot { display: grid; grid-template-columns: 34px 1fr 70px; gap: 8px; align-items: center; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; cursor: pointer; background: var(--bg); }
.robot:hover { border-color: var(--faint); } .robot.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.robot .nm { font-weight: 600; font-family: var(--mono); }
.tag { display: inline-block; font-size: 9.5px; padding: 0 5px; border-radius: 99px; background: var(--ok-soft); color: var(--ok); font-family: Inter, system-ui, sans-serif; font-weight: 500; }
.tag.low { background: var(--accent-soft); color: var(--accent); }
.lbl.rob.low { border-color: #93c5fd; } .robot .st { font-size: 12px; color: var(--muted); }
.robot .gauges { display: grid; gap: 3px; } .robot .g { height: 5px; background: var(--line2); border-radius: 3px; overflow: hidden; } .robot .g i { display: block; height: 100%; }
.robot .num { font-family: var(--mono); font-size: 12px; text-align: right; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-bottom: 10px; }
.tbl th, .tbl td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); } .tbl td.n, .tbl th.n { text-align: right; font-family: var(--mono); }
.tbl tr.tot td { font-weight: 600; border-top: 2px solid var(--line); }
.events { font-family: var(--mono); font-size: 11.5px; } .events div { padding: 2px 0; border-bottom: 1px solid var(--line2); display: grid; grid-template-columns: 56px 1fr; gap: 8px; } .events .t { color: var(--faint); }

dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--card); color: var(--ink); max-width: min(720px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.35); } dialog form { padding: 18px 20px; }
dialog h3 { margin: 0 0 10px; font-family: Fraunces, Georgia, serif; font-weight: 600; font-size: 18px; }
.dlg-actions { display: flex; gap: 8px; margin-top: 14px; } .grow { flex: 1; }
#dlgBody label { display: block; margin: 8px 0 4px; font-size: 12.5px; color: var(--muted); } #dlgBody input[type=text] { width: 100%; }
.about { font-size: 13px; line-height: 1.5; max-height: 60vh; overflow: auto; } .about h4 { margin: 12px 0 4px; } .about ul { margin: 4px 0; padding-left: 18px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 10px; font-size: 13px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; }
.toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 1100px) { .work { grid-template-columns: 230px minmax(0, 1fr) 300px; } }
@media (max-width: 860px) { body { overflow: auto; } .app { height: auto; min-height: 100vh; } .work { grid-template-columns: 1fr; } .side { max-height: 320px; } .center { min-height: 60vh; } .scen input { width: 120px; } }

/* largeur bornée : la colonne centrale ne pousse jamais le panneau de droite hors de l'écran */
.center { min-width: 0; } .side { min-width: 0; } .params, .tabpane { overflow-x: hidden; }
.simbar { min-width: 0; } .simbar #phase { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolbar { flex-wrap: wrap; row-gap: 6px; min-width: 0; } .toolbar #hint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tabs2 { flex-wrap: wrap; } .robot { grid-template-columns: 34px minmax(0, 1fr) auto; } .robot .st { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note { overflow-wrap: anywhere; }
.simbar { flex-wrap: wrap !important; row-gap: 6px; } .simbar .seg, .simbar .btn, .simbar .clock { flex-shrink: 0; }
