:root {
  --bg: #ffffff;
  --bg2: #f4f6f8;
  --line: #e2e6ea;
  --text: #1d2329;
  --muted: #6b7680;
  --rail: #1f2326;
  --rail-hi: #2e3438;
  --accent: #0f8a3c;
  --accent-2: #0b6e2f;
  --danger: #c62828;
  --warn: #b7791f;
  --radius: 8px;
  --shadow: 0 6px 24px rgba(20, 30, 40, .16);
  font-family: Roboto, "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.error { color: var(--danger); margin: 0; }

.btn { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 6px 12px; cursor: pointer; }
.btn:hover { background: var(--bg2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; white-space: nowrap; }

/* connexion */
.login { position: fixed; inset: 0; display: grid; place-items: center; background: linear-gradient(135deg, #e9f3ec, #eef1f5); }
.login-card { width: min(360px, 92vw); background: #fff; padding: 28px; border-radius: 14px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; }
.login-logo { width: 56px; height: 56px; }
.login-card label:not(.check) { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.login-card input:not([type=checkbox]) { padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--text); }
.login-card .btn { padding: 9px; }
.demo-link { font-size: 12px; color: var(--muted); text-align: center; }

/* coquille */
.app { display: flex; height: 100vh; }
.rail { width: 56px; flex: none; background: var(--rail); display: flex; flex-direction: column; align-items: center; color: #fff; }
.rail-logo { width: 56px; height: 56px; display: grid; place-items: center; background: var(--accent); }
.rail-logo img { width: 38px; height: 38px; }
.rail-btn { width: 56px; height: 52px; border: 0; background: none; display: grid; place-items: center; cursor: pointer; color: #b8c0c6; border-left: 3px solid transparent; }
.rail-btn svg { width: 22px; height: 22px; fill: currentColor; }
.rail-btn:hover { background: var(--rail-hi); color: #fff; }
.rail-btn.active { background: var(--rail-hi); color: #fff; border-left-color: var(--accent); }
.rail-fill { flex: 1; }
.rail-clock { display: grid; text-align: center; font-size: 11px; color: #c9d0d5; padding: 8px 0; }
.rail-clock b { font-size: 15px; color: #fff; font-weight: 500; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.top { height: 56px; flex: none; display: flex; align-items: center; gap: 16px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.top h1 { font-size: 20px; font-weight: 500; margin: 0; white-space: nowrap; }
.site-select { font-size: 18px; border: 0; background: transparent; padding: 4px; cursor: pointer; max-width: 260px; }
.search { position: relative; flex: 1; max-width: 420px; margin: 0 auto; }
.search svg { position: absolute; left: 12px; top: 9px; width: 18px; fill: var(--muted); }
.search input { width: 100%; padding: 8px 12px 8px 38px; border-radius: 20px; border: 1px solid var(--line); background: var(--bg2); }
.search-results { position: absolute; top: 40px; left: 0; right: 0; background: #fff; border-radius: 8px; box-shadow: var(--shadow); z-index: 30; max-height: 60vh; overflow: auto; }
.search-results button { display: flex; width: 100%; gap: 10px; padding: 8px 12px; border: 0; background: none; text-align: left; cursor: pointer; }
.search-results button:hover, .search-results button.sel { background: var(--bg2); }
.badge { font-size: 12px; padding: 3px 9px; border-radius: 10px; background: var(--bg2); color: var(--muted); white-space: nowrap; }
.badge.demo { background: #fff4d6; color: #8a6200; }

.page { flex: 1; min-height: 0; }
.plan-page { display: flex; }
.plan-area { flex: 1; position: relative; min-width: 0; background: #fff; }
.plan { position: absolute; inset: 0; overflow: hidden; touch-action: none; }
.plan svg { width: 100%; height: 100%; display: block; user-select: none; }
.plan-chips { position: absolute; left: 14px; top: 12px; z-index: 5; display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 8px; background: #3a4045; color: #fff; border: 0; border-radius: 18px; padding: 4px 14px 4px 4px; cursor: pointer; font-size: 12px; }
.chip b { background: #5a6268; border-radius: 50%; min-width: 26px; height: 26px; display: grid; place-items: center; }
.chip span { display: grid; text-align: left; line-height: 1.15; }
.chip small { font-size: 10px; color: #c7cdd1; }
.chip.soft { background: rgba(255, 255, 255, .9); color: var(--muted); border: 1px solid var(--line); padding: 6px 12px; cursor: default; }
.plan-tools { position: absolute; right: 14px; top: 12px; z-index: 5; display: grid; gap: 4px; }
.tool { width: 32px; height: 32px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; font-size: 16px; }
.legend { position: absolute; left: 14px; bottom: 12px; z-index: 5; display: flex; flex-wrap: wrap; gap: 4px 12px; background: rgba(255, 255, 255, .92); padding: 6px 10px; border-radius: 6px; border: 1px solid var(--line); font-size: 11px; max-width: 60%; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.site-note { position: absolute; right: 14px; bottom: 12px; z-index: 5; margin: 0; font-size: 11px; color: var(--muted); max-width: 35%; text-align: right; }
.empty-plan { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }

/* plan : cases */
.slot-bg { stroke-width: .12; }
.slot.drop .slot-bg { stroke: #111 !important; stroke-width: .35; }
.slot.found .slot-bg { stroke: #e53935 !important; stroke-width: .45; }
.slot.selected .slot-bg { stroke: #111 !important; stroke-width: .3; }
.slot { cursor: pointer; }
.slot text { pointer-events: none; font-family: Roboto, "Segoe UI", sans-serif; }
.veh-card { stroke-width: .12; }
.veh-head { fill: #fff; }
.veh.taken .veh-card { stroke-dasharray: .5 .35; stroke: #fff; stroke-width: .22; }
.veh.too-long .veh-card { stroke: #e53935; stroke-width: .35; }
.veh.dragging { opacity: .35; }

/* panneau de droite */
.side { width: 330px; flex: none; border-left: 1px solid var(--line); display: flex; flex-direction: column; background: #fff; }
.side-tabs { display: flex; border-bottom: 1px solid var(--line); }
.side-tab { flex: 1; border: 0; background: none; padding: 12px 6px; cursor: pointer; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.side-tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 500; }
.side-head { padding: 8px 14px 0; display: flex; justify-content: flex-end; }
.side-head select { border: 0; background: none; cursor: pointer; }
.side-find { padding: 8px 14px; }
.side-find input { width: 100%; padding: 8px 14px; border-radius: 20px; border: 1px solid var(--line); }
.side-list { flex: 1; overflow: auto; }
.side-list.drop-out { outline: 2px dashed var(--accent); outline-offset: -6px; background: #f2faf4; }
.side-empty { padding: 24px 16px; color: var(--muted); text-align: center; }
.vrow { display: grid; grid-template-columns: 40px 1fr auto; gap: 4px 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: center; }
.vrow:hover { background: var(--bg2); }
.vrow.can-drag { cursor: grab; }
.vicon { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; grid-row: span 2; }
.vicon svg { width: 20px; fill: #fff; }
.vicon.off { background: #8d969d; }
.vicon.warn { background: var(--warn); }
.vnum { font-weight: 700; font-size: 15px; }
.vtime { font-weight: 700; text-align: right; }
.vtags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: 10px; padding: 1px 6px; border-radius: 4px; background: #d9dde0; color: #333; white-space: nowrap; }
.tag.g { background: var(--accent); color: #fff; }
.tag.o { background: #f6e0b5; color: #7a5200; }
.tag.r { background: #f8d4d4; color: #8e1d1d; }
.vsub { grid-column: 2 / 4; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.level { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; justify-self: end; }
.level .bar { width: 24px; height: 11px; border: 1.5px solid #555; border-radius: 2px; position: relative; padding: 1px; }
.level .bar::after { content: ""; position: absolute; right: -4px; top: 2px; width: 2px; height: 4px; background: #555; }
.level .bar i { display: block; height: 100%; background: #43a047; }
.level .bar i.mid { background: #9e9e9e; }
.level .bar i.low { background: #e53935; }

.side-detail { flex: 1; overflow: auto; padding: 14px; }
.detail h2 { margin: 0 0 2px; font-size: 18px; }
.detail h3 { margin: 18px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.kv select, .kv input { width: 100%; padding: 4px 6px; border: 1px solid var(--line); border-radius: 5px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* tableaux */
.table-page { display: flex; flex-direction: column; }
.filters { display: flex; gap: 10px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.filters input:not([type=checkbox]), .filters select { padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; }
.filters input#parc-find, .filters input#sv-find { min-width: 260px; }
.table-wrap { flex: 1; overflow: auto; }
.grid { border-collapse: collapse; width: 100%; font-size: 13px; }
.grid th { position: sticky; top: 0; background: var(--bg2); text-align: left; font-weight: 500; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; z-index: 1; }
.grid td { padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover { background: #f7f9fa; }
.grid td.num { font-weight: 700; }
.grid select { padding: 3px 6px; border: 1px solid var(--line); border-radius: 5px; max-width: 280px; }
.state { display: inline-flex; align-items: center; gap: 6px; }
.state i { width: 8px; height: 8px; border-radius: 50%; background: #43a047; }
.state.immobilise i { background: var(--danger); }
.state.maintenance i { background: #ef6c00; }
.state.reserve i { background: #7e57c2; }
.state.reforme i { background: #757575; }

/* fenêtre, menu, message */
.modal { position: fixed; inset: 0; background: rgba(20, 25, 30, .35); display: grid; place-items: center; z-index: 50; }
.modal-card { position: relative; background: #fff; border-radius: 12px; box-shadow: var(--shadow); width: min(520px, 94vw); max-height: 90vh; overflow: auto; padding: 22px; }
.modal-close { position: absolute; right: 10px; top: 8px; border: 0; background: none; font-size: 24px; cursor: pointer; color: var(--muted); }
.menu { position: fixed; z-index: 60; background: #fff; border-radius: 8px; box-shadow: var(--shadow); padding: 6px 0; min-width: 200px; }
.menu div { padding: 6px 14px; font-size: 12px; color: var(--muted); }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 14px; cursor: pointer; }
.menu button:hover { background: var(--bg2); }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #263238; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 70; box-shadow: var(--shadow); max-width: 90vw; }
.toast.err { background: var(--danger); }
.ghost { position: fixed; z-index: 80; pointer-events: none; background: var(--accent); color: #fff; font-weight: 700; padding: 6px 12px; border-radius: 6px; box-shadow: var(--shadow); transform: translate(-50%, -120%); }

@media (max-width: 900px) {
  .side { width: 280px; }
  .search { display: none; }
  .legend { display: none; }
}
@media (max-width: 680px) {
  .plan-page { flex-direction: column; }
  .side { width: auto; height: 42%; border-left: 0; border-top: 1px solid var(--line); }
  .site-select { font-size: 15px; }
  .top h1 { display: none; }
}
